TheLettuceMaster
TheLettuceMaster

Reputation: 15734

Using Limit on Delete SQL queries

I had this query

DELETE c FROM review_comments AS c 
LEFT JOIN users AS u 
ON u.user_id = c.user_id
WHERE c.comment = '{$comment}'
AND u.username = '{$user}'
LIMIT 1;

It did not work until I removed LIMIT 1;

It said: 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 6

Is this the incorrect usage of LIMIT 1 in this instance? I had a same query without joining tables and LIMIT 1 worked fine?

Upvotes: 0

Views: 134

Answers (1)

Rob Paller
Rob Paller

Reputation: 7786

I don't think LIMIT can be used with multi-table referenced DELETE statements in MySQL.

Upvotes: 4

Related Questions