Mysql 正在寻找从不存在的数据中删除片段的方法

Mysql 正在寻找从不存在的数据中删除片段的方法,mysql,sql,database,mariadb,Mysql,Sql,Database,Mariadb,我有以下几张表 report_pre { id, date} report_sections {id,report,data} 我想用以下sql代码删除表片段:- DELETE FROM report_sections WHERE report=ANY( SELECT rs.report FROM report_sections rs WHERE NOT EXISTS ( SEL

我有以下几张表

report_pre    { id, date}
report_sections   {id,report,data}
我想用以下sql代码删除表片段:-

DELETE
FROM
report_sections
WHERE
report=ANY(
    SELECT 
        rs.report 
    FROM 
        report_sections rs 
    WHERE 
        NOT EXISTS (
            SELECT
                rp.id
            FROM
                report_pre rp
            WHERE
                rp.id=rs.report
        )
)
但我得到的信息是:

#1093-无法在FROM子句中为更新指定目标表“report\u sections”

我做错了什么? 我已经尝试了不同的方法,但到目前为止还没有找到解决办法。
请帮助。

这可能会满足您的需要:

DELETE rs
    FROM report_sections rs LEFT JOIN
         report_pre rp
         on rp.id = rs.report
    WHERE rp.id IS NULL;
这将删除
report\u部分
中所有在
report\u pre
中没有匹配记录的行

我认为错误信息在您的原始信息中非常清楚。您可以通过使用附加的子查询层来解决这个问题。但是,学习
join
方法来解决这个问题是很有趣的