DELETE FROM `TreePaths` WHERE `descendant` IN (SELECT `descendant` FROM `TreePaths` WHERE `ancestor`= 0x04);
我得到
#1093 - 您不能指定目標表「的TreePaths」的更新中FROM子句
我怎樣才能讓刪除工作?
更新: 表結構:
CREATE TABLE TreePaths (
ancestor VARBINARY(16) NOT NULL,
descendant VARBINARY(16) NOT NULL,
PRIMARY KEY (`ancestor`, `descendant`),
FOREIGN KEY (`ancestor`) REFERENCES Library(iD),
FOREIGN KEY (`descendant`) REFERENCES Library(iD)
);
表數據:
ancestor descendant
01 01
02 02
02 03
03 03
02 04
04 04
02 05
04 05
05 05
02 06
04 06
06 06
07 07
08 08
09 09
10 10
顯示你的表'structure'和'數據'。 – diEcho
我猜想它同樣的問題 http://stackoverflow.com/questions/45494/sql-delete-cant-specify-target-table-for-update-in-from-clause – Zohaib
閱讀這一個:HTTP ://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html – diEcho