Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 UPDATE Using more than one table

Author  Topic 

Compkitty
Starting Member

24 Posts

Posted - 2005-05-25 : 11:14:25
Is there a way to update one column using conditions based on two or more tables?

ie.

UPDATE <table1>
SET col02 = (SELECT ColNew From <table2> WHERE <Table2>.ColNew = <table3>.Colold AND <Table2>.Col001 = <Table3>.Col001

Is this possible?, If so, please clue a newbie in..
THANKS TONS!!!

Sully
Starting Member

30 Posts

Posted - 2005-05-25 : 12:15:31
I believe you would have to use a join and you would have to insure one value returned in your select. Plus, are you trying to update every row in table1?





Stuck in neutral in a pedal to the metal world,
Sully
Go to Top of Page

Compkitty
Starting Member

24 Posts

Posted - 2005-05-25 : 12:26:50
I was able to formulate the answer.. THANKS THOUGH
Go to Top of Page

Sully
Starting Member

30 Posts

Posted - 2005-05-25 : 12:46:16
Great, and you're welcome.


Stuck in neutral in a pedal to the metal world,
Sully
Go to Top of Page
   

- Advertisement -