MySQL won't ORDER BY Swedish characters åäö not working even though collation is correct

collation, mysql

Solution

No idea about the default behaviour, but the correct syntax is:

SELECT customer_id, customer_name
FROM customers
WHERE isActive = '1'
ORDER BY customer_name COLLATE utf8_swedish_ci ASC

Problem

This query: `SELECT customer_id, customer_name FROM customers WHERE isActive = '1' ORDER BY customer_name ASC` Outputs: ``` +-------------+-----------------------+ | customer_id | customer_name | +-------------+-----------------------+ | 1 | Äname | | 2 | Aname | | 3 | Bname | +-------------+-----------------------+ ``` Why does it not sort the special swedish characters, even though I have collation `utf8_swedish_ci` ``` SHOW TABLE STATUS FROM myDatabase WHERE name = 'customers'; +-------------+----------------------------+ | Name | Engine | Collation | +-------------+----------------------------+ | customers | MyISAM | utf8_swedish_ci | +-------------+----------------------------+ ``` I even tried to put the collation in my query: ``` SELECT * FROM customers WHERE isActive = 1 COLLATE utf8_swedish_ci ORDER BY customer_name ASC ``` But then I get: ``` Error Code: 1253. COLLATION 'utf8_swedish_ci' is not valid for CHARACTER SET 'binary' ```

Original source