Mysql:使用IN子查询DELETE

时间:2011-03-16 18:25:44

标签: mysql

DELETE FROM images WHERE image_id IN(
    (SELECT i.image_id FROM images i
    LEFT JOIN ads a ON i.ad_id=a.id
        WHERE ISNULL(a.id))
)

我需要完成此查询。任何帮助将不胜感激。谢谢;)

1 个答案:

答案 0 :(得分:1)

DELETE i
    FROM images i
        LEFT JOIN ads a ON i.ad_id=a.id
    WHERE ISNULL(a.id)