automaton
automaton

Reputation: 3128

MySQL LIMIT not working

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..

Upvotes: 6

Views: 14118

Answers (3)

Rocco
Rocco

Reputation: 1085

LIMIT work like this: LIMIT (page - 1) * post_per_page, post_per_page

Upvotes: 1

Nick Rolando
Nick Rolando

Reputation: 26177

LIMIT 48 , 57

will show 57 records following the 48th record.

Try

LIMIT 48 , 9

http://php.about.com/od/mysqlcommands/g/Limit_sql.htm

Upvotes: 4

Ry-
Ry-

Reputation: 225263

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.

Upvotes: 16

Related Questions