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 中的重音符号?


- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01