Å vs å 在 mysql 查询中不匹配 - 如何进行不区分大小写的匹配


Å vs å is not matching in mysql query - how to do case insensitive match

我有一个PHP开发的丹麦网站。我正在使用mysqli.

我在数据库字段中有像 Daugård 和 Århus 这样的词,称为标签。

我希望在运行如下所示的查询时将这两个值作为结果。

Query : select * from table_name where tags like '%år%'; 
Expected result : Daugård and Århus both
Actual result : Daugård

现在它执行区分大小写的匹配,只返回道加德单词。我尝试通过函数 set_charset('utf8'( 将字符集动态更改为 utf8,但它不起作用。

'tags' field is 'utf8_general_ci'table collation is 'utf8_general_ci'和我的database collation is 'latin1_swedish_ci'的整理。

帮我如何实现这一点?

为避免排序规则问题,请在比较前对"标签"使用大小写转换函数:

select * from table_name where lcase(tags) like '%år%';

我可能会错过一些东西,因为 MySQL 对我来说并不那么熟悉。我知道函数 LOWER(tags( 在 Oracle 中可以完成这项工作,只要搜索的模式也是小写的。