我在两个名为'email'的表中有一个公共列,如果在表B中找到匹配,我需要从表A中删除记录。
这会有用吗?有更好的方法吗?
DELETE b.* FROM `tableA` b
JOIN `tableB` u
ON u.email = b.email
答案 0 :(得分:4)
DELETE FROM tableA WHERE email IN (SELECT email FROM tableB)
答案 1 :(得分:3)
DELETE FROM TableA WHERE email IN (SELECT b FROM TableB)
答案 2 :(得分:1)
删除*
DELETE b
FROM `tableA` b
JOIN `tableB` u ON u.email = b.email