duandun2136 2014-10-17 07:28
浏览 147
已采纳

如何在mysql中使用多个和or运算符

i use the following statement but it does not working properly.

$query = "select * from employee where status ='Active' and employee_id! ='".$data['employee_id']."') and (first_name like '$data%' or last_name like '$data%' or batch like '$data%' or job_title like '$data%' or company like '$data%' ORDER BY first_name";
      $result = mysql_query($query);

Like i need to fetch all result but not employee_id=5; but i get the employee_id=5 result;is there any issue in query and other simplest way to use this query

  • 写回答

3条回答 默认 最新

  • dongzhiyan5693 2014-10-17 11:16
    关注

    in your code $data['employee_id'] and like '$data% use both same variable you need to change $data for search value. it is overwrite.

    do this and check

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?