无法通过通配符在php和mysql中通过id查找数据

时间:2019-02-26 10:21:20

标签: php mysql

查询如下:

 $query = "
  SELECT * FROM cbs_tasks 
  WHERE team_member_id = $uid and task_title LIKE '%".$search."%'
  OR task_desc LIKE '%".$search."%' 
  OR task_cat LIKE '%".$search."%' 
  OR task_priority LIKE '%".$search."%' 
  OR status LIKE '%".$search."%'
 ";

1 个答案:

答案 0 :(得分:0)

将“或”部分放在方括号中,您将获得所需的输出。

$query = "
  SELECT * FROM cbs_tasks 
  WHERE team_member_id = $uid and (task_title LIKE '%".$search."%'
  OR task_desc LIKE '%".$search."%' 
  OR task_cat LIKE '%".$search."%' 
  OR task_priority LIKE '%".$search."%' 
  OR status LIKE '%".$search."%' )
 ";