0

两张表,如下。

tbl-1
------
userid
teamid
teamname
elimimated


tbl-2
------
teamid
selectedteam

如果 tbl-2.selectedteam 为空,我想更新 tbl-1.eliminated = 1?如何在一个 sql 命令中实现这一点?

4

1 回答 1

2
UPDATE tbl-1 SET eliminated=1 
WHERE teamid IN (
                    SELECT t2.teamid FROM tbl-2 AS t2
                    RIGHT JOIN tbl-1 AS t1
                    ON t2.teamid = t1.teamid
                    WHERE t2.selectedteam IS NULL
               );    
于 2013-09-09T20:22:29.897 回答