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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update from an inner join? 1

Status
Not open for further replies.

daglugub37

Technical User
Oct 21, 2003
201
US
OK I have 2 identical tables.

table1
col_ID
colA
colB

table2
col_ID
colA
colB

How can I update table1.colA, table1.colB from table2, using col_ID as a join?
 
Code:
[COLOR=blue]Update[/color] Table1
[COLOR=blue]Set[/color]    Table1.ColA = Table2.ColA,
       Table1.ColB = Table2.ColB
[COLOR=blue]From[/color]   Table1
       [COLOR=blue]Inner[/color] [COLOR=blue]Join[/color] Table2
         [COLOR=blue]On[/color] Table1.Col_Id = Table2.Col_Id

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
This will work: (*tested A+ seal of approval)

Code:
update table1 set colA = b.colA, colB = b.colB from table1 a inner join table2 b on a.col_ID = b.col_ID

[monkey][snake] <.
 
something like this should work.

Select a.colA
from table1 a inner join table2 b on a.col_Id = b.col_id
Update table1
set a.cola = b.colb
 
thanks all, for some reason i was making it more complicated then it needed to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top