How to remove accents in MySQL?(如何删除 MySQL 中的重音符号?)
问题描述
我刚刚编译了一个包含 100 万个地名的数据库.我将在自动完成小部件中使用它来查找城市.很多这些地方都有重音......我希望能够在用户键入不带重音的名称时找到记录.
I've just compiled a database of 1 million place names. I'm going to use it in an auto-complete widget to look up cities. A lot of these places have accents... I want to be able to find records when a user types the name without an accent.
为了做到这一点,我在第 2 列中添加了名称的无重音副本.许多这些记录仍然是空白的,所以我想写一个查询来填充它们.这在直接的 MySQL 中可能吗?如果是,怎么办?
In order to do this, I've got a 2nd column with an unaccented copy of the name. Many of these records are still blank, so I want to write a query to fill them in. Is this possible in straight MySQL? If so, how?
推荐答案
如果您为列设置了适当的排序规则,那么该字段中的值将自然地与它的无重音等效值相等.
If you set an appropriate collation for the column then the value within the field will compare equal to its unaccented equivalent naturally.
mysql> SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT 'é' = 'e';
+------------+
| 'é' = 'e' |
+------------+
| 1 |
+------------+
1 row in set (0.05 sec)
这篇关于如何删除 MySQL 中的重音符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何删除 MySQL 中的重音符号?


基础教程推荐
- 带更新的 sqlite CTE 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01