从x左联接y中删除x.a在表y中不为空

时间:2019-04-16 13:41:08

标签: mysql

如何从表A中删除表B中不存在的记录?

我尝试过:

DELETE FROM
    x
LEFT JOIN
    y
ON
    x.image_hash IS NOT NULL IN y

1 个答案:

答案 0 :(得分:0)

适当使用EXISTSNOT EXISTS子句。

DELETE FROM x WHERE <NOT> EXISTS (SELECT 1 FROM y WHERE y.<something> = x.<some_column> AND <some more conditions>