MySQL查询删除表A中电子邮件匹配的表A中的记录

时间:2013-11-05 15:49:14

标签: mysql

我在两个名为'email'的表中有一个公共列,如果在表B中找到匹配,我需要从表A中删除记录。

这会有用吗?有更好的方法吗?

DELETE b.* FROM `tableA` b
JOIN `tableB` u
ON u.email = b.email

3 个答案:

答案 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