Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL LIMIT not working

Tags:

sql

mysql

I have a MySQL 5.0 server, and I'm running this query:

    SELECT *
    FROM deals
    WHERE expires > "2012-05-25 19:37:58"
    AND city =2
    ORDER BY UIN
    LIMIT 48 , 57

And it's returning:

Showing rows 0 - 29 (57 total, Query took 0.0036 sec)

Am I doing something wrong? I expect 9 rows, 48-57..

like image 832
automaton Avatar asked May 26 '12 00:05

automaton


People also ask

Does LIMIT work in MySQL?

In MySQL the LIMIT clause is used with the SELECT statement to restrict the number of rows in the result set. The Limit Clause accepts one or two arguments which are offset and count. The value of both the parameters can be zero or positive integers.

Does LIMIT work on update MySQL?

Yes, it is possible to use UPDATE query with LIMIT in MySQL.

What is the max LIMIT MySQL?

The MySQL maximum row size limit of 65,535 bytes is demonstrated in the following InnoDB and MyISAM examples. The limit is enforced regardless of storage engine, even though the storage engine may be capable of supporting larger rows.


1 Answers

The second parameter to LIMIT is not an offset, it's a length relative to the offset. So if you want 9 rows, it would be LIMIT 48, 9.

like image 177
Ry- Avatar answered Nov 15 '22 07:11

Ry-