[英]What is wrong with this MySQL query?
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
It throws an error: 它抛出一个错误:
#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
If I remove the LIMIT 1, it works, but I want it on for security measures. 如果我删除了LIMIT 1,它可以工作,但是我希望将其用于安全措施。
As I see it, the LIMIT
is only valid for single table deletions 如我所见,
LIMIT
仅对单个表删除有效
http://dev.mysql.com/doc/refman/5.0/en/delete.html http://dev.mysql.com/doc/refman/5.0/en/delete.html
For the multiple-table syntax, DELETE deletes from each tbl_name the rows that satisfy the conditions.
对于多表语法,DELETE从每个tbl_name中删除满足条件的行。 In this case, ORDER BY and LIMIT cannot be used.
在这种情况下,不能使用ORDER BY和LIMIT。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.