If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Complex Update

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-04, 09:41
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
Complex Update

I have some code that runs in SQL Server that I need to translate into DB2

Code:
update dbo.stg_joc_tbl 
set office = s.office
from dbo.stg_joc_tbl j, dbo.REF_NA_SALES_XREF_TBL s
where j.district = s.district_code
I have done this once but I have lost the script. And I have also forgoten what I did. I know I did a nested select statment something like

Code:
update dbo.stg_joc_tbl 
set office = s.office
from dbo.stg_joc_tbl j
where j.district in (select distinct district_code from REF_NA_SALES_XREF_TBL)
If anyone can look at this and help me remember it would be greatly apreciated.
Jim
__________________
------------
And back to SQL Server....I always find my way home
View my Linkedin profile
Reply With Quote
  #2 (permalink)  
Old 09-29-04, 09:55
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You're almost there

Code:
update dbo.stg_joc_tbl  j
set j.office = (select s.office from dbo.REF_NA_SALES_XREF_TBL s
where j.district = s.district_code)
Reply With Quote
  #3 (permalink)  
Old 09-29-04, 10:17
JDionne JDionne is offline
Registered User
 
Join Date: Aug 2002
Location: Charlotte NC
Posts: 663
Quote:
Originally Posted by n_i
You're almost there

Code:
update dbo.stg_joc_tbl  j
set j.office = (select s.office from dbo.REF_NA_SALES_XREF_TBL s
where j.district = s.district_code)

Yup That was it!!!! Thanx for the help.
Jim
__________________
------------
And back to SQL Server....I always find my way home
View my Linkedin profile
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On