我试图执行此查询,但我收到错误#1064。
delete from tableABC WHERE ID in (select ID from `TABLEXYZ` where `qty` = 0);
但以下声明有效
从tableABC WHERE ID中选择*(从
TABLEXYZ
中选择ID在哪里qty
= 0);
答案 0 :(得分:2)
以下是答案:
要使用具有where条件的子查询的删除查询,请执行以下操作:
DELETE a FROM `tableABC` AS a JOIN (SELECT ID FROM `tableXYZ` WHERE `qty`=0) as b on b.ID = a.ID