My problem is, that MySQL orders characters before numbers. To give a quick example, we have this strings in a database:
3, a, 2, 1, b
And ORDER BY statement would return this:
a, b, 1, 2, 3
But I want it to be:
1, 2, 3, a, b
My database is utf8_unicode_ci, but that doesn’t help. It still produces the wrong result. (I can’t just check if they are numbers and then sort them to the top because an item could also be named “2something” and has to be before “asomething”). Any ideas?
Edit: I found the problem. In the database (which stores users), I was ordering by CONCAT(name, login), and the name was NULL. MySQL orders NULL always at the top, so the characters were top of the numbers (the name field of them was an empty string).
ORDER BYshould work in the desired manner if the column type ischaracterorvarchar.