简体   繁体   English

如何在mysql中从右到左语言数据排序?

[英]How to sort right to left language data in mysql?

I have a MySQL database that is storing Persian data and information. 我有一个存储波斯数据和信息的MySQL数据库。 the information are names and I want to sort names by alphabet. 信息是名称,我想按字母对名称进行排序。 but MySQL don't know Persian language, and some other right to left languages. 但是MySQL不懂波斯语和其他一些从右到左的语言。

How can I sort them? 如何分类?

and my other problem is with phpmyAdmin, phpmyAdmin can't show Persian language data and show some character instead of that 我的另一个问题是phpmyAdmin,phpmyAdmin无法显示波斯语言数据并显示一些字符而不是那个

About the first question; 关于第一个问题; as fancyPants said, use the proper collation and you should be fine. 如fancyPant所说,请使用适当的排序规则,您应该会很好。 Sorting is handled by collations and there is a utf8 Persian collation available. 排序由排序规则处理,并且有utf8波斯语排序规则可用。

About your second problem: 关于第二个问题:

Almost certainly what is happening is that you're improperly storing the data. 几乎可以肯定,正在发生的事情是您存储的数据不正确。 As Sid M said, knowing what you've tried and how your system is running would be a big help, but these questions almost always end up being misconfigured or poorly written software. 正如Sid M所说,了解您的尝试以及系统的运行方式将有很大帮助,但这些问题几乎总是以错误的配置或编写不良的软件而告终。 phpMyAdmin and MySQL can deal just fine with multiple character sets. phpMyAdmin和MySQL可以处理多个字符集。 Presumably, you'll want to use utf8. 大概,您将要使用utf8。

Set up your database and tables properly, then make sure your client application is configured properly (likely using SET NAMES 'UTF8' or mysql_set_charset('utf8') , but read the links for more detail than is worth including here). 正确设置数据库和表,然后确保正确配置了客户端应用程序(可能使用SET NAMES 'UTF8'mysql_set_charset('utf8') ,但请阅读链接以获取比此处包含的内容还详细的信息。

See https://wiki.phpmyadmin.net/pma/Garbled_data and How to display UTF-8 characters in phpMyAdmin? 请参阅https://wiki.phpmyadmin.net/pma/Garbled_data如何在phpMyAdmin中显示UTF-8字符? for starters and SQL injection that gets around mysql_real_escape_string() for way more information than you probably wanted to learn :) 对于初学者和SQL注入,它绕过mysql_real_escape_string()以获得比您可能想学习的更多信息:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM