What makes a negative value for MySQL LIMIT?

So what happens when you use a negative value in a LIMIT clause? Will there be negative consequences (a small pun)?

I do not see any documentation on this issue, and on the MySQL forums, as far as I remember, sux.

Background: I am using MySQL CE 5.5.20. I wrote a stored procedure that takes an int parameter and uses it for a LIMIT clause. I needed a way to return all rows if I wanted, so I tried passing -1 for the limit parameter in my storage procedure / procedure, and it worked.

+5
source share
2 answers

According to the documentation , it must be a non-negative integer

LIMIT , SELECT. LIMIT , ( , ).

, , , , mysql , .

SQL . int , . -

IF myparam >= 0 THEN
    SELECT * FROM `mytable` LIMIT myparam;
ELSE
    SELECT * FROM `mytable`;
END IF;
+3

MySQL .

The error in MySQL

0

All Articles