简体   繁体   中英

Delete Rows from pecific Table on Multi-table SELECT

I have this SQL statement for MSQL that selects exactly what I want (I am looking for and trying to remove old data):

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

Now, I need a way to delete those rows from only the table called reviews . How would I go about doing this?

the DELETE statement would be,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM