Overlapping results on mysql query when using limit/offset

Lili Jason

I'm new to databases, and im not sure why this isnt working.

My objective is to get all the users in a database except the first one. I would also like this to be sortable, so it contains ORDER BY.

I finally got pagination to work, but the query is returning overlapping results on different pages

QUERY:

SELECT * FROM `users` as `User`  WHERE '1'='1' AND `User`.`id` > '1'  ORDER BY User.active ASC LIMIT 0, 10

i get these back (here is their IDs in the order i got) 32,18,19,16,15,14,13,12,11,2

Now with the LIMIT part set to 10,100, i get these back 32,20,19,2,11,12,13,14,15,15

I'm not sure why i get overlapping results. Help?

Thanks :)

Jain

Try this:

SELECT * FROM users as User WHERE '1'='1' AND User.id > 1 ORDER BY User.id ASC LIMIT 0,10

OR TRY something simple:

SELECT * FROM users WHERE users.id > 1 LIMIT 0,10

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Safari displays overlapping elements when using media query

From Dev

Not retrieving correct results with mysql query using parentheses

From Dev

Not retrieving correct results with mysql query using parentheses

From Dev

Ordering results of MySQL query (using join)

From Dev

MySQL Query: Using group by and getting unreal results

From Dev

When selecting * FOR UPDATE in mysql using innodb does it lock all the results that match the query?

From Dev

extracting results of a SELECT query when using PDO

From Dev

Concatenating LINQ query results when using loops

From Dev

MySQL - Using results from one query in another query

From Dev

Using results in one query to use in another query - Orace MySql

From Dev

Display "x results found" or "no results found" when returning MySQL Query results

From Dev

Select query mysql results 'û' appears when I search for 'u'

From Dev

PHP MySQL Query of view returns 0 results when there should be a result

From Dev

MySQL query returns null results when used in php

From Dev

MySQL Limit query by time when there's not enough results

From Dev

PHP STMT MySQL query returning LIKE results when set to equals

From Dev

mysql slow query when results are less than limit

From Dev

Versioning for MySQL Query Results

From Dev

MySQL fallback query if no results

From Dev

Inaccurate results with MySql query

From Dev

MySQL query fliltering results

From Dev

MySQL query filtering results

From Dev

Utilizing MySQL query results

From Dev

Array with MySQL query results

From Dev

Transpose the results of a MySQL query

From Dev

Inaccurate results with MySql query

From Dev

Mysql query returns no results

From Dev

mysql query to fetch these results

From Dev

Using PHP SESSION Variables to store MySQL query results

Related Related

  1. 1

    Safari displays overlapping elements when using media query

  2. 2

    Not retrieving correct results with mysql query using parentheses

  3. 3

    Not retrieving correct results with mysql query using parentheses

  4. 4

    Ordering results of MySQL query (using join)

  5. 5

    MySQL Query: Using group by and getting unreal results

  6. 6

    When selecting * FOR UPDATE in mysql using innodb does it lock all the results that match the query?

  7. 7

    extracting results of a SELECT query when using PDO

  8. 8

    Concatenating LINQ query results when using loops

  9. 9

    MySQL - Using results from one query in another query

  10. 10

    Using results in one query to use in another query - Orace MySql

  11. 11

    Display "x results found" or "no results found" when returning MySQL Query results

  12. 12

    Select query mysql results 'û' appears when I search for 'u'

  13. 13

    PHP MySQL Query of view returns 0 results when there should be a result

  14. 14

    MySQL query returns null results when used in php

  15. 15

    MySQL Limit query by time when there's not enough results

  16. 16

    PHP STMT MySQL query returning LIKE results when set to equals

  17. 17

    mysql slow query when results are less than limit

  18. 18

    Versioning for MySQL Query Results

  19. 19

    MySQL fallback query if no results

  20. 20

    Inaccurate results with MySql query

  21. 21

    MySQL query fliltering results

  22. 22

    MySQL query filtering results

  23. 23

    Utilizing MySQL query results

  24. 24

    Array with MySQL query results

  25. 25

    Transpose the results of a MySQL query

  26. 26

    Inaccurate results with MySql query

  27. 27

    Mysql query returns no results

  28. 28

    mysql query to fetch these results

  29. 29

    Using PHP SESSION Variables to store MySQL query results

HotTag

Archive