MySQL按照漢字拼音字母排序,mysql漢字排序

來源:互聯網
上載者:User

MySQL按照漢字拼音字母排序,mysql漢字排序

如果MySQL編碼格式為GBK字元集,可直接在查詢語句後面添加

order by name asc;  --進行升序排序

如果是utf8字元集,需要在排序的時候對欄位進行轉碼,

order by convert(name using gbk) asc;

附:查看MySQL編碼方式

SHOW VARIABLES LIKE 'character%';



character_set_client  為用戶端編碼方式;

character_set_connection  為建立串連使用的編碼;

character_set_database  資料庫的編碼;

character_set_results  結果集的編碼;

character_set_server  資料庫伺服器的編碼;


作者:itmyhome


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.