我有一个项目表和另一个报告。每个报告都有一个外键链接到正在报告的项目。
我正在尝试删除此查询中显示的所有项目:
SELECT items.id, title, SUM(weight) AS total_weight, SUM(weight)*10/views AS score
FROM items, reports
WHERE items.id = reports.item_id
GROUP BY items.id
HAVING score >= 50;
尝试这样的事情:
DELETE items
FROM (SELECT items.id, title, SUM(weight) AS total_weight, SUM(weight)*10/views AS score
FROM items, reports
WHERE items.id = reports.item_id
GROUP BY items.id
HAVING score >= 50)
AS T;
给我这个错误信息:
ERROR 1109 (42S02): Unknown table 'items' in MULTI DELETE