表里只有这两条数据
id     name
1      汤姆
2      jerry如果用select * from table1 where name like '%汤%',或用select * from table1 where name like '%j%'
可以正确搜出
id     name
1      汤姆以及id     name
2      jerry
-----------------------------------------------
但如果用select * from table1 where name like '%a%',就居然能把中文纪录搜出来,结果集为
id     name
1      汤姆我字符集用的是UTF8,mysql接触的少,还请各位朋友帮忙解决一下

解决方案 »

  1.   

    字符集的原因。 参考一下这个贴子。http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
    MySQL 中文显示乱码
      

  2.   

    show create table table1 ;
    show variables like 'char%';set names 'utf8' 试一下。
      

  3.   

    回楼上大大,运行过了,没用啊
    在mysql-front中看到的状态是这样的
    id name
    1  "汤姆"
    2  "Jerry"不过用php把值取出来在网页上显示一点问题也没有
      

  4.   

    1、"students","CREATE TABLE `students` (\n  `student_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n  `stuname` varchar(255) NOT NULL,\n  `gender` varchar(32) NOT NULL,\n  `habbit` varchar(20) NOT NULL,\n  `birth` datetime NOT NULL,\n  `mobile` varchar(15) NOT NULL,\n  PRIMARY KEY (`student_id`),\n  UNIQUE KEY `student_id` (`student_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8"2、"character_set_client","utf8"
    "character_set_connection","utf8"
    "character_set_database","utf8"
    "character_set_filesystem","binary"
    "character_set_results","utf8"
    "character_set_server","utf8"
    "character_set_system","utf8"
    "character_sets_dir","C:\\Program Files\\MySQL\\MySQL Server 5.1\\share\\charsets\\"
      

  5.   

    select id,name, hex(name) from students
    看一下你表中存储的内容id name
    1  "汤姆"
    2  "Jerry"
      

  6.   

    1,"汤姆","C3A6C2B1C2A4C3A5C2A7E280A0"
    2,"Jerry","4A65727279"
      

  7.   

    1,"汤姆","C3A6C2B1C2A4C3A5C2A7E280A0"你插入的时候不对。汤姆 的UTF8编码是  E6B1A4E5A786 每汉字3个字节!C38CC380C384C2B7 你插入的时候 当然你的 character_set_client = latin1==================
    结论,你数据库中存储的本身不对,
    解决方法,把数据倒出,然后清空后再导入。
      

  8.   

    如果你的记录都是以这种方式插入的,则你应该 在 mysql 命令行工具中 set names 'latin1'; 然后再 select * from students INTO OUTFILE 'sss.dat';
    然后 delete from students ; 再 回到你的  mysql-front中 set names 'utf8'
    然后把数据插入。
      

  9.   

    nndx,终于搞定了,原来是Zend_Db链接里有参数要加
    新建db链接时要加参
    $pdoParams = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8\';');
    加参以后添加的“汤姆”总算是E6B1A4E5A786 了,感谢楼上各位,接分接分