2011-01-24 212 views
0
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 

它拋出一個錯誤:這個MySQL查詢有什麼問題?

#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 

如果我刪除限制1,它的工作原理,但我想它的保安措施。

+0

你指的是什麼安全措施? – BoltClock 2011-01-24 19:57:05

回答

4

當我看到它時,LIMIT僅適用於單個表刪除

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. In this case, ORDER BY and LIMIT cannot be used.

+0

謝謝。猜猜我可以自己想出一個。 – 2011-01-24 20:11:36

1

限制不能在多表中刪除使用。請參閱DELETE語法文檔。