I have query like this
SELECT user_id FROM user_rights ORDER BY user_id DESC;
Why it gives me those messed up numbers?
USER_ID
4
4
4
4
3
3
21
21
21
21
21
21
20
20
It does not order the numbers as expected.
PROOF : http://sqlfiddle.com/#!2/c753a/1
I understand that they may be ordered alphabetically or numerical, buy i don’t understand why is this result so weird…
It’s because the
user_idis not numeric.TRY this,
SQLFiddle Demo
Another solution is to change the datatype of your column
user_idtoint