0

我需要从基于 JOIN 的 MySQL 表中删除行。

表 1 - 球员

id      gang
--------------
1       5
2       8
3       0

表 2 - 行动

id      player
----------------
1       2
2       1

我需要(伪代码)

DELETE FROM 'actions' WHERE player=(SELECT id FROM players WHERE gang=5)

所以它检查动作表,如果它找到一个在 gang 5 中的玩家,它会删除该条目。

对不起,如果我没有意义

4

2 回答 2

1

试试这个,

DELETE  a
FROM    Actions a
        INNER JOIN Players b
            ON a.player = b.ID
WHERE   b.gang = 5
于 2013-04-19T11:08:26.830 回答
0
DELETE FROM 'actions' WHERE player IN (SELECT id FROM players WHERE gang=5)
于 2013-04-19T11:12:31.340 回答