MySQL把ÅÄÖ作为AAO? [英] MySQL treats ÅÄÖ as AAO?

查看:109
本文介绍了MySQL把ÅÄÖ作为AAO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个查询给出了完全相同的结果:

These two querys gives me the exact same result:

select * from topics where name='Harligt';
select * from topics where name='Härligt';

怎么可能?好像mysql在搜索时将åäö翻译成aao。有没有办法把它关掉?

How is this possible? Seems like mysql translates åäö to aao when it searches. Is there some way to turn this off?

我使用utf-8编码到处都是我所知道的。

I use utf-8 encoding everywhere as far as i know. The same problem occurs both from terminal and from php.

推荐答案

是的,这是非语言特定unicode中的标准行为排序规则。

Yes, this is standard behaviour in the non-language-specific unicode collations.

9.1.13.1。 Unicode字符集


为了进一步说明,utf8_general_ci和utf8_unicode_ci中的以下均等性(对于比较效果或进行搜索时,请参见第9.1.7.7节排序规则的效果示例):

To further illustrate, the following equalities hold in both utf8_general_ci and utf8_unicode_ci (for the effect this has in comparisons or when doing searches, see Section 9.1.7.7, "Examples of the Effect of Collation"):

Ä= A
Ö= O
Ü= U

Ä = A Ö = O Ü = U

另请参见整理效果的示例

您需要


  • 使用没有此功能的归类(即 utf8_bin ,但有其他后果)

  • use a collation that doesn't have this "feature" (namely utf8_bin, but that has other consequences)

仅对查询使用不同的排序规则 。这应该工作:

use a different collation for the query only. This should work:

select * from topics where name='Harligt' COLLATE utf8_bin;


如果你想做不区分大小写 LIKE 具有Ä= A umlaut转换。我不知道是不区分大小写的mySQL排序规则,也不会做这种隐式的变音。

it becomes more difficult if you want to do a case insensitive LIKE but not have the Ä = A umlaut conversion. I know no mySQL collation that is case insensitive and does not do this kind of implicit umlaut conversion. If anybody knows one, I'd be interested to hear about it.

相关:

  • Looking for case insensitive MySQL collation where "a" != "ä"
  • MYSQL case sensitive search for utf8_bin field

这篇关于MySQL把ÅÄÖ作为AAO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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