如何搜索多列,此代码搜索单列,请自定义我的代码
$keywords= "search keywords";
$keywords= htmlspecialchars($keywords);
$keywords= mysqli_real_escape_string($con, $keywords);
$countSql_s = "SELECT *, MATCH(website) AGAINST ('%".$keywords."%') AS score FROM search WHERE MATCH(website) AGAINST ('%".$keywords."%') ORDER BY score DESC";
答案 0 :(得分:0)
只需改变你的" WHERE"包括每列的检查,如下所示:
... WHERE MATCH(website) AGAINST('%".$keywords."%') > 5
AND MATCH(username) AGAINST('%".$keywords."%') > 5
...
答案 1 :(得分:0)
您需要将表格更改为:
ALTER TABLE --table name-- ADD FULLTEXT fulltext_search (column1,colum2,column3);
然后你可以像这样搜索:
MATCH (column1,column2) AGAINST ('%".$keywords."%')