DELETE * FROM `products` WHERE `products_id` IN (
FROM `products` p, `products_suppliers` ps
WHERE p.`products_id` = ps.`products_id`
AND (p.`products_id` <> 215 AND p.`products_id` <> 305)
if i interpret your first query, it says "delete all products that have a supplier and that aren't 215 or 305"
Correct. Actually delete all products whose ids arent 215 or 305 and supplier_id is 1. I forgot to mention AND supplier_id = 1 but thats fine.
do you have products without a supplier? and you want to keep those? if so, why?
No - all products are assigned a supplier. I dont want to keep the deleted product_ids in the other tables - I'll do the manual cascading later - just wanted to know if I could delete these ids using SQL - without using a server-side language to iterate through.
So is there any way to delete this way ?
DELETE FROM `table1` WHERE `id` IN
(SELECT `id` FROM `table1` WHERE `id` <> 215 AND `id` <> 305)