使用普通搜索进行全文搜索

时间:2015-12-26 04:36:27

标签: php mysql

我试图进行一个查询,该搜索将使用2个附加条件进行全文搜索。全文部分工作正常。到目前为止我尝试过这些,但都没有用:

$query  = "SELECT * FROM table ";
$query .= "WHERE MATCH(title) ";
$query .= "AGAINST('".$title."') ";
$query .= "AND state='".$state."' ";
$query .= "AND county='".$county."' ";
$query .= "LIMIT 5 ";

$query  = "SELECT * FROM table ";
$query .= "WHERE MATCH(title) ";
$query .= "AGAINST('".$title."') ";
$query .= "MATCH(state) AGAINST('".$state."') ";
$query .= "MATCH(county) AGAINST('".$county."') ";
$query .= "LIMIT 5 ";

我刚从评论中尝试了这个,但是我在%$ state%:

附近收到错误1064

$query  = "SELECT * FROM table ";
$query .= "WHERE MATCH(title) ";
$query .= "AGAINST('".$title."') ";
$query .= "AND state LIKE %".$state."% ";
$query .= "AND county LIKE %".$county."% ";
$query .= "LIMIT 5 ";

$query  = "SELECT * FROM table ";
$query .= "WHERE title ";
$query .= "LIKE %".$title."% ";
$query .= "AND state LIKE %".$state."% ";
$query .= "AND county LIKE %".$county."% ";
$query .= "LIMIT 5 ";

0 个答案:

没有答案