开发者

Code Igniter OR AND multiple Where clause

Using CodeIgniter, I'd like to do a multiple search using OR in the Where clause.. something like this:

$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-开发者_JAVA百科>db->query($sql, $searchPara);

the query above gives an error message, and also I am not sure how to include the search on the job.title = $searchPara... in the same SQL statement

Can someone please help me with this?

Thanks heaps


Error in SQL because of comma after 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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜