Windows server 2000 ,PHP+Apache+MySQL模糊查询迷惑!

我在设计了一个用户查询系统,想使用模糊查询技术,遇到了这样的问题,请高手赐教:
SQL语句是:
select * from users where name like '%$name%'
在测试的时候,我想查询姓名中含有“刘”的

输入“刘”

得到查询结果:

刘怀东 吕优 周琳 刘阳

从结果看,得到的结果与读音的关系好象比字型的关系还更密切,请问各位高手,怎么样才能得到我所要的模糊查询结果
运行环境Windows server 2000 ,PHP+Apache+MySQL
---------------------------------------------------------------

这是mysql字符集设置的问题

有两种办法:

1、编译MYSQL,在configure的时候加一个--with-charset=gbk

2、将MYSQL目录下my-example.cnf复制一份为my.cnf,然后打开my.cnf,将其中的default-character-set=latin1 改为default-character-set=gbk就可以了
---------------------------------------------------------------

select * from users where name like binary '%$name%'
用这个查询可以解决.

Published At
Categories with Web编程
Tagged with
comments powered by Disqus