I am facing sorting issue in mysql
See the output of below query:
select astrologers.id,astrologers.name,chat_online,online,experience from `astrologers`
where `astrologers`.`status` = '1'
order by experience asc limit 10;
| id | name | chat_online | online | experience |
|---|---|---|---|---|
| 15 | Astro Anoop | 0 | 0 | 3 |
| 20 | Test Astro2 | 0 | 0 | 3 |
| 3 | Test anoop | 0 | 0 | 5 |
| 4 | Anoop Kumar trivedi | 0 | 0 | 5 |
| 7 | Test | 0 | 0 | 5 |
| 58 | Neeraj yadav | 1 | 0 | 5 |
| 45 | Satish Kumar Gupta | 1 | 1 | 10 |
| 56 | AP Sharma | 1 | 0 | 15 |
| 40 | VG Astrologer App | 1 | 0 | 55 |
In above result id 58 (Neeraj yadav) is at 6th position but when I run the same query with limit 3, same id 58 (Neeraj yadav) is at 3rd position:
select astrologers.id,astrologers.name,chat_online,online,experience
from `astrologers`
where `astrologers`.`status` = '1'
order by experience asc limit 3;
| id | name | chat_online | online | experience |
|---|---|---|---|---|
| 20 | Test Astro2 | 0 | 0 | 3 |
| 15 | Astro Anoop | 0 | 0 | 3 |
| 58 | Neeraj yadav | 1 | 0 | 5 |
The 3rd row in above result should be id 3 (Test anoop) but it gives id 58 (Neeraj yadav)
Is this bug in mysql?
3and not58? They both have the exact sameexperienceso any one of the three is correct. Is there another column that you are wanting to sort by in addition toexperience? Perhaps you wantORDER BY experience, id?