使用CodeIgniter,我想在Where子句中使用OR进行多重搜索..这样的事情:
$sql = "select employee.first_name, employee.last_name, employee.phone_number, job.title,
FROM employee, job
WHERE employee.jobID = job.jobID
AND employee.deleted = 0
AND (employee.first_name = $searchPara OR employee.last_name= $searchPara)
ORDER BY employee.last_name";
return $this->db->query($sql, $searchPara);
上面的查询给出了一条错误消息,而且我也不确定如何在相同的SQL语句中将job.title = $ searchPara ...包含在搜索中
有人可以帮帮我吗?
谢谢堆
答案 0 :(得分:2)
由于job.title
$sql = "select employee.first_name, employee.last_name, employee.phone_number, job.title
FROM employee, job
WHERE employee.jobID = job.jobID
AND employee.deleted = 0
AND (employee.first_name = ? OR employee.last_name = ?)
ORDER BY employee.last_name";
return $this->db->query($sql, array($searchPara, $searchPara));