我想搜索的字段名字和姓氏的关键字加入MySQL的2场,同时
$q1 = strtolower($_GET["q"]);
$q=str_replace(" ","%",$q1);
$sql = "select DISTINCT users.*, user_id FROM users WHERE $email_filter
firstname LIKE '%$q%' OR lastname LIKE '%$q%' ORDER BY lastname";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) { echo $results }
这同时搜索是我到目前为止,问题是,如果你使用李四作为一个例子,一旦你键入约翰找到它,能源部它发现它,但李四......没有结果
您需要连接第一和姓领域,并比较*是*您搜索字符串,按[下使用mysql concat()在WHERE子句?](http://stackoverflow.com/questions/303679/using-mysql-concat-in-where-clause) – 2012-01-13 23:56:32