Hi!
I have mysql database with about 4000 users.
For listing users I am using this query:
SELECT DISTINCT nl_gost.id as kid,nl_gost.naziv as knaziv FROM nl_gost ORDER BY knaziv limit 300,400

and with HTML select I am changing limit 0-100, 100-200 etc. and 0- COUNT.

When listing all users, without LIMIT, it's working fine, but when I
turn on LIMIT, ORDER doesn't work well.

in for exemple, limit from:
0-100 I have users from a-d
100-200 I have users from d-h

and

200-300 I have users from e-f!!!!

Could anyone tell me why, and how can I solve this problem.

I tried with GROUP BY knaziv, without DISTINCT ,
but, it's just doesn't work 😕

Thanks in advance
Cash

    • [deleted]

    Check the mysql docs, the syntax for LIMIT is:

    LIMIT OFFSET, LENGTH

    so LIMIT 200,300 will fetch 300 records, starting from the 200th record.

    It does NOT select records 200 through 300

    What you want is
    LIMIT 0,100
    LIMIT 100,100
    LIMIT 200,100

    Also, LIMIT has nothing at all to do with a-b or e-f.

      yap, thats right.
      thanks very much vincente! 🙂

      cash

        Write a Reply...