DELETE
LIB, REL
FROM
test_library_song LIB
INNER JOIN
test_relation REL
ON
LIB.book_id = REL.book_id
WHERE
REL.user_id = '1'
AND
REL.book_id = '400'
LIMIT 1
它会抛出错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 13
如果我删除LIMIT 1,它可以工作,但我希望它能用于安全措施。
答案 0 :(得分:4)
在我看来,LIMIT
仅对单个表删除有效
http://dev.mysql.com/doc/refman/5.0/en/delete.html
对于多表语法,DELETE从每个tbl_name中删除满足条件的行。在这种情况下,不能使用ORDER BY和LIMIT。
答案 1 :(得分:1)
LIMIT不能用于多表删除。请参阅DELETE语法文档。