各位大大,知道mysql里select * from TABLE where column like '%中%',查出来结果不对,怎么解决?
网上有人说把MYSQL里的字符集修改成gb2312,还有种是把查询语句改成select * from TABLE where column binary like '%中%'.
网上有人说把MYSQL里的字符集修改成gb2312,还有种是把查询语句改成select * from TABLE where column binary like '%中%'.
解决方案 »
- #1690 - BIGINT UNSIGNED value is out of range in .... INT(11) UNSIGNED
- mysql中可以使用转义字符'\001'吗?
- ████莪在000webhost申请了一个免费的MYSQL空间、但是怎么也连不上去 ████
- 高分求助 PostgreSQL动态行转列
- 求句SQL~~~~~~~
- 谁有postgres管理工具EMS SQL Manager for PostgreSQL2007的注册码或者注册机?
- 这段代码为什么不能执行
- 谁来帮我看看这个sql怎么写啊,mysql就是报错,急
- mysql也有dual表吗?
- 我想向大数据方向发展 现在培训啥好 Linux OR Mysql OR Other
- MySql安装时问题?
- 关于addslashes(),mysql_real_escape_string()以及stripslashes()的问题
[code]
/*DDL Information For - test.lkclass*/
--------------------------------------Table Create Table
------- -----------------------------------------
lkclass CREATE TABLE `lkclass` (
`id` int(11) NOT NULL,
`classname` varchar(20) DEFAULT NULL,
`grade` varchar(20) DEFAULT NULL,
`scoreid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
set names gbk;
select * from lkclass where grade like '%年级%';
select * from lkclass where grade binary like '%年级%';
[/code]结果:
query result(5 records)
id classname grade scoreid
1 一班 三年级 1
2 二班 三年级 2
3 三班 三年级 3
4 四班 三年级 4
5 一班 四年级 5 query result(5 records)
id classname grade scoreid
1 一班 三年级 1
2 二班 三年级 2
3 三班 三年级 3
4 四班 三年级 4
5 一班 四年级 5
/*DDL Information For - test.lkclass*/
--------------------------------------Table Create Table
------- -----------------------------------------
lkclass CREATE TABLE `lkclass` (
`id` int(11) NOT NULL,
`classname` varchar(20) DEFAULT NULL,
`grade` varchar(20) DEFAULT NULL,
`scoreid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
set names gbk;
select * from lkclass where grade like '%年级%';
select * from lkclass where grade binary like '%年级%';
select * from TABLE where column binary like '%中%'
这样用就对的,mysql里查一个中文字就会出现这个错误,希望这贴也对新人有用.再次感谢各位!