2011-08-11 48 views
4

我需要在SQL Server中的命令应该基本上是这样的IF-THEN在SQL Server

If table1.columnx = 1 
then update table2 set comumnx = 1 

它应该是很简单,但我不能为我的生活想出了一个解决方案。

+1

您正在使用哪种RDBMS,以及哪个版本? – 2011-08-11 17:29:21

回答

11
update t2 
set columnx = 1 
from table1 t1 
inner join table2 t2 
on t1.id = t2.id 
where t1.columnx = 1 
+1

嗨德里克,这有助于很多! – Newkidirus

+1

您能否将此标记为正确答案?谢谢 –