首页 > 解决方案 > 为什么当我使用像“select * from table_name where character='⺎'”这样的选择语句然后返回'尤','⼪','⺎'和'⺐'

问题描述

mysql查询返回不匹配的记录,如查询字段character='兀'但匹配出,尤,⺎,⺐?

我把我的mysql从5.7更新到8.0,在5.7,这个问题比较常见

drop  database if exists `chinese_sort`;
create database `chinese_sort` default  charset utf8mb4;

use `chinese_sort`;
create table `chinese_character_dict_standard_version`(
                                                        `id` bigint primary key auto_increment,
                                                        `character` char(1) not null comment '字',
                                                        `chinese_pinyin` varchar(50) default '' comment '拼音',
                                                        `stroke_num` tinyint not null default 0 comment '笔画数',
                                                        `four_corner_num` varchar(5) default '' comment '四角号码',
                                                        `unicode` varchar(12) not null comment 'unicode码',
                                                        `utf16` varchar(12) not null comment 'utf16码'
);
insert into chinese_character_dict_standard_version(`character`, unicode, utf16)
values('尢','5c22','\u5c22'),
      ('⼪','2f2a','\u2f2a'),
      ('⺎','2e8e','\u2e8e'),
      ('⺐','2e90','\u2e90');
SET NAMES utf8mb4 collate utf8mb4_unicode_ci;
select * from chinese_character_dict_standard_version
where `character` ='⺎';

我希望select语句的输出是'兀',但实际输出是兀'、'尤'、'⺎'、'⺐'

标签: mysqlpattern-matchingcjkchinese-locale

解决方案


推荐阅读