Reputation: 4979
im trying to execute this query but i'm getting error #1064.
delete from tableABC WHERE ID in (select ID from `TABLEXYZ` where `qty` = 0);
But the following statement works
select * from tableABC WHERE ID in (select ID from
TABLEXYZ
whereqty
= 0);
Upvotes: 0
Views: 58
Reputation: 4979
Here is the answer:
to use a delete query with subquery which has a where condition, do the following:
DELETE a FROM `tableABC` AS a JOIN (SELECT ID FROM `tableXYZ` WHERE `qty`=0) as b on b.ID = a.ID
Upvotes: 2