Search the MySQL manual:

5.2.9 How MySQL Optimises LIMIT

In some cases MySQL will handle the query differently when you are using LIMIT row_count and not using HAVING:

User Comments

Posted by Bill Bozeman on Wednesday December 18 2002, @5:27pm[Delete] [Edit]

Here is an example of how to use Limit:

The first example will limit the result to the first 10 items.
<font color="blue">SELECT name FROM customers LIMIT 10</font>

This example will limit the result to 10 rows, starting with row 5.
<font color="blue">SELECT name FROM customers LIMIT 5 , 10</font>

If you only use one parameter, it will be the number of rows to return, if you use two
parameters, it will be where to start, and then the number to return.

Bill

Posted by [name withheld] on Wednesday December 18 2002, @5:27pm[Delete] [Edit]

I'm not going to hazard a guess at what exactly
is going on internally, but this

LIMIT 10, -1

will return the 11th record through end of table
(indexing starts at 0).

Posted by J. Rose on Friday May 16 2003, @1:26pm[Delete] [Edit]

If you're retrieving your records in order of a unique indexed key column, it's much faster to paginate results using something like this:

select * from table1 where key>LAST_KEY order by key limit 10;

where LAST_KEY is the highest key value you retrieved in your last query, than to do

select * from table1 order by key limit LAST_RESULT_ROW_PLUS_ONE, 10;

where LAST_RESULT_ROW_PLUS_ONE is 0, then 10, then 20, as you step through pages of 10.

At least, it was in my MySQL 4 database.

Posted by [name withheld] on Thursday July 3 2003, @1:27am[Delete] [Edit]

If you write LIMIT -1 all records that meet your criteria will be returned - like without LIMIT. I found it useful when generating queries, like in this PHP code:
if(!isset($lim))$lim = -1;
$query = "select * from table limit $lim";
$result = mysql_query($query);

Posted by BenM on Monday July 28 2003, @6:28am[Delete] [Edit]

Do not use negative numbers in the LIMIT clause (as suggested in other comments). The current behaviour,
"LIMIT on negative numbers are treated as big positive numbers", is documented as an error and is marked as "The following problems are known and will be fixed in due time:" Therefore relying on the current situation is not safe as future revisions may fix this error. See "Open Bugs / Design Deficiencies in MySQL" in the current manual (28 Jul 03) for more info.

Add your own comment.