从多表SELECT上的特定表中删除行

时间:2013-03-18 15:00:59

标签: mysql sql sql-delete

我有SQL MSQL语句可以准确选择我想要的内容(我正在寻找并尝试删除旧数据):

SELECT * 
FROM `reviews` as r
JOIN items as i
ON i.item_id = r.item_id
JOIN master_cat as c
ON i.cat_id = c.cat_id
WHERE category is null

现在,我需要一种方法只从名为reviews的表中删除这些行。我该怎么做呢?

1 个答案:

答案 0 :(得分:2)

DELETE语句将是,

DELETE r
FROM   reviews r
       INNER JOIN items i ON i.item_id = r.item_id
       INNER JOIN master_cat c ON i.cat_id = c.cat_id
WHERE  category is null