Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with complex update command 1

Status
Not open for further replies.

SelbyGlenn

Technical User
Oct 7, 2002
444
GB
...well complex for me anyway! I'm fairly new to SQL so I'm still on that steep learning curve.

Here's the problem: I have three tables with the following columns:

Table1: Appcode, Email
Table2: Appcode, ContactID
Table3: ContactId, Email.

I need to copy the email data from table1 to table 3 but I can't work out how to compare across three tables.

Please help!

Thanks in advance,

Glenn
BEng MCSE CCA
 
Try this?

Code:
UPDATE table3
SET email = t1.email
FROM table1 t1
  JOIN table2 t2 ON t1.appcode = t2.appcode
  JOIN table3 t3 ON t2.contactid = t3.contactid

--James
 
Excellent! That did the trick.

Thanks for the qick reply James

Glenn
BEng MCSE CCA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top