寻找不区分大小写的 MySQL 排序规则,其中“a”是!= ”ä”

发布于 2024-08-17 07:43:16 字数 201 浏览 1 评论 0原文

我正在寻找 UTF8 的 MySQL 排序规则,它不区分大小写,并区分“a”和“ä”(或者更一般地说,区分变音/重音字符及其“纯”形式)。 utf8_general_ci 执行前者,utf8_bin 执行后者,bot none 执行两者。如果没有这样的排序规则,我该怎么做才能在 WHERE 子句中尽可能接近?

I'm looking for a MySQL collation for UTF8 which is case insensitive and distinguishes between "a" and "ä" (or more generally, between umlauted / accented characters and their "pure" form). utf8_general_ci does the former, utf8_bin the latter, bot none does both. If there is no such collation, what can I do to get as close as possible in a WHERE clause?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情泪▽动烟 2024-08-24 07:43:16

我的建议是使用 utf8_bin 并在 WHERE 子句中强制比较的两边都为大写或小写。

My recommendation would be to use utf8_bin and in your WHERE clause, force both sides of your comparison to upper or lower case.

厌味 2024-08-24 07:43:16

它在这里使用 utf8_german2_ci 作为排序规则工作正常:

SELECT * FROM tablename WHERE fieldname LIKE "würz%" COLLATE utf8_german2_ci

It works fine here with utf8_german2_ci as collation:

SELECT * FROM tablename WHERE fieldname LIKE "würz%" COLLATE utf8_german2_ci
粉红×色少女 2024-08-24 07:43:16

我像这样检查了 utf8_bin

CREATE TABLE tmp2 (utf8_bin VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_bin);
INSERT INTO tmp2 VALUES ('nói');

select * from tmp2 where utf8_bin='noi';

I checked utf8_bin like this

CREATE TABLE tmp2 (utf8_bin VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_bin);
INSERT INTO tmp2 VALUES ('nói');

select * from tmp2 where utf8_bin='noi';
诠释孤独 2024-08-24 07:43:16

您可以尝试utf8_swedish_ci,它不区分大小写,并区分aä(但将例如ü视为< em>y)。

排序规则与语言相关,并且德语似乎在 MySQL 中没有自己的排序规则。 (我看了你的个人资料,上面写着你是德国人。)

You could try utf8_swedish_ci, it's both case insensitive and distinguishes between a and ä (but treats e.g. ü like y).

Collations are language-dependent, and it seems German doesn't have its own collation in MySQL. (I had a look at your profile, which says you're German.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文