2011-08-11 101 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

您能否將此標記爲正確答案?謝謝 –