MySQL以符号作为首字母排序 [英] MySQL sorting with symbols as first letter

查看:155
本文介绍了MySQL以符号作为首字母排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下行的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆