我有一个SQL查询:
$cond = "";
if($cid >0 )
{
$quali = $this->getCandidatesQualification($cid);
$cond = "WHERE emp_qualification LIKE '%$quali%'";
}
$sql = "SELECT
emp_job_id,emp_job_profie,emp_qualification,emp_experience
FROM
tbl_emp_data
$cond
ORDER BY job_add_date DESC LIMIT 0,10
";
$res = $this->db->returnArrayOfObject($sql,$pgin = 'no', $odr='no');
如果emp_qualification
字段等于any_graduate
,我想要的是我想要为候选人选择所有工作,即使他的资格是BA
。
答案 0 :(得分:1)
所以将WHERE子句修改为
WHERE emp_qualification LIKE '%$quali%'
OR emp_qualification = 'any_graduate'
答案 1 :(得分:0)
$cond = '';
if($cid >0 ) {
if ($this->getCandidatesQualification($cid) != 'any_graduate') {
$cond = "WHERE emp_qualification LIKE '%{$this->getCandidatesQualification($cid)}%'";
}
}
简化,试试这个