I need to delete records in a table that are based on joins
of other tables.
Getting the data via joins is easy, but I'm struggling to
figure out how to
delete items from one table based on a join from multiple
tables.
Heres one example:
I have two tables, items and categories.
To get the rows from items, I can use a join:
SELECT *
FROM items INNER JOIN
categories ON items.categoryID =
categories.categoryID
WHERE (items.categoryID = 9) OR
(categories.categoryParentID = 9)
Now, what if I want to delete the records from items, but not
delete any
records from categories?
Can I just use?:
DELETE FROM items INNER JOIN
categories ON items.categoryID =
categories.categoryID
WHERE (items.categoryID = 9) OR
(categories.categoryParentID = 9)
-Darrel