How can I sort non-English strings in MySQL?

爱⌒轻易说出口 提交于 2019-12-23 15:03:39

问题


CREATE TABLE IF NOT EXISTS `gujarati` (
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `gujarati` (`name`) VALUES
('ક'),
('દિનેશ'),
('ખા'),
('ગા'),
('થા'),
('થ'),
('કા'),
('મયૂર'),
('છત્ર'),
('ત્ર'),
('ક્ષ'),
('તા'),
('એક'),
('બોલ્ડ'),
('જ'),
('ટી'),
('મી'),
('હા'),
('યા'),
('ના'),
('ધી'),
('સો'),
('લા'),
('ઝા'),
('ણ્ણા');

This is my table that stores the Gujarati language. How can I sort this data in a MySQL database?


回答1:


Set the gujarati's table collation to the one coresponding to this language, then simply sort with ORDER BY - it's supposed to work out of the box




回答2:


Please use this meta tag :

meta http-equiv="Content-Type" content="text/html; charset=UTF-8" 

And use this code in php :

mysql_query ("set character_set_results='utf8'");


来源:https://stackoverflow.com/questions/6664831/how-can-i-sort-non-english-strings-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!