MySQL以符号作为首字母排序 [英] MySQL sorting with symbols as first letter
问题描述
我有一个包含以下行的MySQL表:
I have a MySQL table with these rows:
¡Hola!
¿Qué tal?
Fine
Hello
Adiós
How are you?
如何对它们进行排序以获得此结果:
How can I sort them to obtain this result:
Adiós
Fine
Hello
¡Hola!
How are you?
¿Qué tal?
我希望MySQL忽略非字母数字字符.
是否可以快速进行此操作而无需创建具有简化值的新列?
I want MySQL to ignore non alphanumeric characters.
It's possible to do this fast without making a new column with a simplified value?
推荐答案
不幸的是,在MySQL中执行此操作令人头疼.
It's a notorious pain in the neck to do this in MySQL, unfortunately.
请参见 MySQL可以替换多个字符吗?
尝试一下:
ORDER BY replace(replace(phrase,'¿',''),'¡','')
在对短语进行排序时,从您的短语中删除西班牙语前缀标点符号.一个希望MySQL具有REGEXP_REPLACE函数.
to remove the Spanish-language prefix punctuation from your phrases as they are sorted. One wishes MySQL had a REGEXP_REPLACE function.
关于性能,除非您有成千上万的短语,否则使用ORDER BY函数应该没问题.几十个,没问题.
As for the performance, you should be fine with ORDER BY functions unless you have zillions of phrases. Dozens, no problem.
这篇关于MySQL以符号作为首字母排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!