Reputation: 35
Using CodeIgniter and I'd like to search multiple search collumns for a value. 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->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.
Upvotes: 0
Views: 2123
Reputation: 9299
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));
Upvotes: 2