条件update,多谢啦

条件update,谢谢啦

table1: id status table2Id table2: id status

  1 1 1 1 0

  2 1 2 2 0

  3 1 1

  4 0 2

table2Id为外键 要求当table1的 table2Id = n的 所有status均为1时,将table2的 id = table2Id行的status 更新为1



update table2

set status=1

where 1=(select min(status) from table1 where table2Id=table2.id)




UPDATE table1 a,table2 b

SET b.status=1

WHERE a.table2id=b.id and a.status=1

条件update,多谢啦

相关文章:

你感兴趣的文章:

标签云: