我试图从包含表A的“选择内部联接”中存在ID的表A中删除,类似于:
Delete from TableA where ID in
(Select Distinct A.ID from TableA A
Inner Join TableC C
Inner Join TableJ J
Inner Join Table J J2
On J.VendorID=J2.VendordID
and J.Title=J2.Title
and A.C_ID=C.C_ID
and J.ID=A.J_ID
and J2.ID=C.J_ID)
Select的工作方式就像我想要的一样(令人惊讶),但我不断收到错误消息
1093 - You can't specify target table 'TableA' for update in FROM clause
我认为这意味着您无法尝试从子查询中包含的表中删除。无论如何,我可以进行重组吗?
最佳答案
您不需要使用子查询。
Delete A from TableA A
Inner Join TableC C
Inner Join TableJ J
Inner Join TableJ J2
On J.VendorID = J2.VendordID
and J.Title = J2.Title
and A.C_ID = C.C_ID
and J.ID = A.J_ID
and J2.ID = C.J_ID
关于mysql - 使用“从同一表中选择内部联接”删除,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48290844/