我需要根据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)
因此,它会检查通过操作表,如果找到第5组中的玩家,则会删除该条目。
对不起,如果我没有意义
答案 0 :(得分:1)
试试这个,
DELETE a
FROM Actions a
INNER JOIN Players b
ON a.player = b.ID
WHERE b.gang = 5
答案 1 :(得分:0)
DELETE FROM 'actions' WHERE player IN (SELECT id FROM players WHERE gang=5)