3

このクエリ:

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'
4

1 に答える 1

4

デフォルトの動作についてはわかりませんが、正しい構文は次のとおりです。

SELECT customer_id, customer_name
FROM customers
WHERE isActive = '1'
ORDER BY customer_name COLLATE utf8_swedish_ci ASC
于 2012-12-04T15:28:59.917 に答える