DELETE `contact`
FROM `contact` ct
INNER JOIN `contact_user` cu ON cu.contact_id=ct.id
WHERE ct.id=4 && ct.block_id=5671 && cu.user_id=1
致命:SQLSTATE [42S02]:找不到基表或视图:1109未知 MULTI DELETE中的表'contact'; SQL:DELETE
contact
FROMcontact
ct INNER JOINcontact_user
cu ON cu.contact_id = ct.id WHERE ct.id = 4 &安培;&安培; ct.block_id = 5671&& cu.user_id = 1
答案 0 :(得分:4)
由于您已为表Alias name
定义了contact
,因此您需要使用别名而不是原始表名。试试这个
DELETE ct
FROM contact ct
INNER JOIN contact_user cu
ON cu.contact_id = ct.id
WHERE ct.id = 4
AND ct.block_id = 5671
AND cu.user_id = 1
或删除contact
表
DELETE contact
FROM contact
INNER JOIN contact_user cu
ON cu.contact_id = contact.id
WHERE contact.id = 4
AND contact.block_id = 5671
AND cu.user_id = 1
答案 1 :(得分:4)
因为您已为表定义了别名,所以应该使用它。同时将&&
替换为and
。
DELETE `ct` --`contact`
FROM `contact` ct
INNER JOIN `contact_user` cu ON cu.contact_id=ct.id
WHERE ct.id=4 and ct.block_id=5671 and cu.user_id=1