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 2005 Forums
 Transact-SQL (2005)
 Update table where column values match

Author  Topic 

syno
Starting Member

6 Posts

Posted - 2008-07-20 : 06:08:33
Hello Guys

I am new to these forums and I need some help writing some SQL. Basically I want to update column 1 in table 1 where the values in table 1, columns 2, 3, and 4 and table 2, columns 2, 3 and 4 are the same.

Thank you

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-20 : 06:45:03
[code]update t1
set col1 = <some value>
from table t1 inner join tablet2 t2
on t1.col2 = t2.col2
and t1.col3 = t2.col3
and t1.col4 = t2.col4[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-07-21 : 10:23:34
Do you have any primary and foreign key relation ship for these two tables
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-21 : 10:28:23
quote:
Originally posted by VGuyz

Do you have any primary and foreign key relation ship for these two tables


OP has specified clearly the relationship b/w the tables in his initial post.
Go to Top of Page
   

- Advertisement -