2017-08-25 67 views
1

我有一些问题,有两个表,它们与值ID进行通信。 现在,我将来自柱具有值“Nein”一个,但只有当在表b的值是“0”和 如果a.id设置的值= b.id.SQL:设置值的条件

我该怎么做? 感谢

回答

0

你需要在像UPDATE语句一个加入:

UPDATE a set ColumnA='Nein' from TableA a inner join TableB b on a.id=b.id WHERE b.ColumnB='0' 
0

请尝试以下查询。因为在这里我不确定这个id是表中的主列,所以我使用了“in”子句。

update A 
set A.a ='Nein' 
where A.id in (select A.id from A ,B 
where A.id = B.id and B.b='0') 
0

尝试用

update A a set a.a='Nein' 
where a.id in (select b.id from B b where B.b='0' and a.id=b.id); 
+0

(这部作品在MySQL的 - 只是尝试) – Sampisa