php mysql like 实现多关键词搜索的方法

PHP100 2019-03-28

或者叫,分词检索数据库

$res = mysql_query("select * from peter where id like '%中草药%' and '%6%'"); //这样写是报错的;

$res = mysql_query("select * from peter where id like '%中草药%' or '%6%'"); //而这样写是正确的;奇怪~

 

$res = mysql_query("select * from peter where id like '%中草药%' and id like '%6%'"); //这样写是正确的;

$res = mysql_query("select * from peter where id like '%中草药%' or id like '%6%'"); //这样写都是正确的;

相关推荐