我想要:
piščanec = mysql 中的 piscanec。我的意思是,我想搜索 piscanec 来找到 piščanec。
所以 č 和 c 是相同的,š 和 s 等等......
我知道可以使用正则表达式来完成,但这很慢:-( LIKE 还有其他方法吗?我也经常使用全文搜索。
更新:
select CONVERT('čšćžđ' USING ascii) as text
不起作用。产生: ??????
最佳答案
声明具有排序规则 utf8_generic_ci
的列。此排序规则认为 š 等于 s 并且 č 等于 c:
create temporary table t (t varchar(100) collate utf8_general_ci);
insert into t set t = 'piščanec';
insert into t set t = 'piscanec';
select * from t where t='piscanec';
+------------+
| t |
+------------+
| piščanec |
| piscanec |
+------------+
如果您不想或不能使用utf8_generic_ci
列的排序规则 - 也许您在该列上有唯一索引并希望将 piščanec 和 piscanec 视为不同的? - 您只能在查询中使用排序规则:
create temporary table t (t varchar(100) collate utf8_bin);
insert into t set t = 'piščanec';
insert into t set t = 'piscanec';
select * from t where t='piscanec';
+------------+
| t |
+------------+
| piscanec |
+------------+
select * from t where t='piscanec' collate utf8_general_ci;
+------------+
| t |
+------------+
| piščanec |
| piscanec |
+------------+
FULLTEXT 索引应该直接使用列排序规则;您不需要定义新的排序规则。显然全文索引只能在列的存储排序规则中,所以如果你想使用utf8_general_ci
用于搜索和 utf8_slovenian_ci
为了排序,你必须使用 use collate
按顺序:
select * from tab order by col collate utf8_slovenian_ci;
关于mysql - 如何在mysql中搜索使重音字符与非重音字符相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12949800/