2012-12-04 33 views
2

這個查詢:MySQL不會ORDER BY瑞典字符AAO無法正常工作,即使排序規則是正確

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

輸出:

+-------------+-----------------------+ 
| customer_id | customer_name   | 
+-------------+-----------------------+ 
|   1 | Äname     | 
|   2 | Aname     | 
|   3 | Bname     | 
+-------------+-----------------------+ 

爲什麼它不是特殊字符瑞典排序,即使我有整理utf8_swedish_ci

SHOW TABLE STATUS FROM myDatabase WHERE name = 'customers'; 

+-------------+----------------------------+ 
| Name  | Engine | Collation  | 
+-------------+----------------------------+ 
| customers | MyISAM | utf8_swedish_ci | 
+-------------+----------------------------+ 

我甚至試圖把整理我的查詢:

SELECT * FROM customers WHERE isActive = 1 COLLATE utf8_swedish_ci ORDER BY customer_name ASC 

但後來我得到:

Error Code: 1253. COLLATION 'utf8_swedish_ci' is not valid for CHARACTER SET 'binary' 
+0

有什麼_column_整理? –

+0

@ÁlvaroG.Vicario'utf8_swedish_ci' – David

+0

什麼是SHOW CREATE TABLE客戶輸出? –

回答

3

不知道有關默認行爲,但the correct syntax是:

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

似乎工作!謝謝。 – David