The customer service team asked me to sort some hotels in Chinese pinyin. I have never touched on it before and asked some experts in the php Group .. You can obtain either of the two answers. Haha ·~
The following is an example of msyql. The table structure is UTF-8
Method 1,
Copy codeThe Code is as follows:
SELECT 'Hotel _ name'
FROM 'Hotel _ base'
Order by convert ('Hotel _ name'
USING gbk)
COLLATE gbk_chinese_ci
Method 2,
Copy codeThe Code is as follows:
SELECT 'Hotel _ id', 'Hotel _ name', ELT (INTERVAL (CONV (HEX (left (CONVERT ('Hotel _ name'
USING gbk), 1), 16, 10), 0xB0A1, 0xB0C5, 0xB2C1, 0xB4EE, 0xB6EA, 0xB7A2, 0xB8C1, 0xB9FE, 0xBBF7, primary, 0xC0AC, primary, 0xC4C3, 0xC5B6, 0xC5BE, 0xC6DA, 0xC8BB, 0xC8F6, 0 xCBFA, 0 xCDDA, 0xCEF4, 0xD1B9, 0xD4D1), 'A', 'B', 'C', 'D ', 'E', 'F', 'G', 'h', 'J', 'k', 'l', 'M', 'n', 'O ', 'P', 'Q', 'R','s ', 't', 'w', 'x', 'y', 'z') AS PY
FROM pai_base
ORDER BY PY ASC
Method 1 is easier than method 2. Hope to help confused people ~~~