Created
March 8, 2015 14:36
-
-
Save yoku0825/77be0d85c51c6a55e29f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SELECT * FROM t1; | |
+-----+-----------------------+--------------+ | |
| num | val | comment | | |
+-----+-----------------------+--------------+ | |
| 1 | はは | mother | | |
| 2 | まるこ・ぽーろ | dummy | | |
| 3 | ババ | grand mother | | |
| 4 | パパ | daddy | | |
+-----+-----------------------+--------------+ | |
4 rows in set (0.00 sec) | |
mysql> SELECT * FROM t1 ORDER BY val COLLATE utf8_general_ci; +-----+-----------------------+--------------+ | |
| num | val | comment | | |
+-----+-----------------------+--------------+ | |
| 1 | はは | mother | | |
| 2 | まるこ・ぽーろ | dummy | | |
| 3 | ババ | grand mother | | |
| 4 | パパ | daddy | | |
+-----+-----------------------+--------------+ | |
4 rows in set (0.00 sec) | |
-- "ま" が "は" と "バ" の間に入ってきて。。 | |
mysql> SELECT * FROM t1 ORDER BY val COLLATE utf8_unicode_ci; +-----+-----------------------+--------------+ | |
| num | val | comment | | |
+-----+-----------------------+--------------+ | |
| 1 | はは | mother | | |
| 3 | ババ | grand mother | | |
| 4 | パパ | daddy | | |
| 2 | まるこ・ぽーろ | dummy | | |
+-----+-----------------------+--------------+ | |
4 rows in set (0.00 sec) | |
-- 辞書様に並んで良いように見える | |
-- ババは2人いる | |
mysql> INSERT INTO t1 (val, comment) VALUES ('ババ', 'grand mother'); | |
Query OK, 1 row affected (0.00 sec) | |
mysql> SELECT * FROM t1 ORDER BY val COLLATE utf8_general_ci; +-----+-----------------------+--------------+ | |
| num | val | comment | | |
+-----+-----------------------+--------------+ | |
| 1 | はは | mother | | |
| 2 | まるこ・ぽーろ | dummy | | |
| 3 | ババ | grand mother | | |
| 5 | ババ | grand mother | | |
| 4 | パパ | daddy | | |
+-----+-----------------------+--------------+ | |
5 rows in set (0.00 sec) | |
-- まるこ・ぽーろが邪魔だけどババは並んでいる | |
mysql> SELECT * FROM t1 ORDER BY val COLLATE utf8_unicode_ci; +-----+-----------------------+--------------+ | |
| num | val | comment | | |
+-----+-----------------------+--------------+ | |
| 1 | はは | mother | | |
| 3 | ババ | grand mother | | |
| 4 | パパ | daddy | | |
| 5 | ババ | grand mother | | |
| 2 | まるこ・ぽーろ | dummy | | |
+-----+-----------------------+--------------+ | |
5 rows in set (0.00 sec) | |
-- 2人のババは並ばない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment