lejahmie
lejahmie

Reputation: 18253

Why does MySQL not ORDER as expected?

I have a pretty simple MySQL table with team names and id. Team names looks as shown below:

Damer
F11
F12
F15
Herrar
HJ18
HJ20
P15
P16
P11
P12
P8
...

But when I order by ASC or DESC based on teamnames I do not get them in the order i would expect, something like above. Instead I get a list like this:

P15
P16
Damer
F11
F12
F15
Herrar
HJ18
HJ20
P11
P12
P8
...

This makes no sense, why does MySQL start with two names that start with P then one taht starts with D followed by three that starts with F... and finally ends with three teams that start with P again.

Any idea?

MySQL code:

SELECT *
FROM `team`
ORDER BY `team`.`teamname` ASC
LIMIT 0 , 30 

And I am using mysql collation utf8_swedish_ci.

Upvotes: 2

Views: 85

Answers (1)

John Conde
John Conde

Reputation: 219804

You probably have a space before the first character in the names that are out of order.

Upvotes: 4

Related Questions