我有一个查询model.But第二or_where不工作or_where不笨模型工作
模式
$this->db->select('st_student.st_id');
$this->db->from('st_student');
$this->db->where('st_status',1);
$this->db->or_where('st_status',2);
if(($from!='') && ($to!='')){
$this->db->where("ab_date BETWEEN '$from' AND '$to'");
$this->db->or_where("as_date BETWEEN '$from' AND '$to'");
}
$this->db->group_by('st_student.st_id');
$result=$this->db->get();
SQL查询
SELECT `st_student`.`st_id`
FROM (`st_student`)
WHERE `st_status` = 1
OR `st_status` = 2
AND `ab_date` BETWEEN '01/15/2016' AND '01/26/2016'
AND `as_date` BETWEEN '01/15/2016' AND '01/26/2016'
GROUP BY `st_student`.`st_id`
怎么啦在那
与实际编辑OP的原帖的问题是,我们不知道该错误是否是从该小语法错误来还是不来 - 也许是OP要评论? – RamRaider
@Rose你是否得到语法错误或者你没有得到预期的结果? – AnkiiG
我没有得到预期的结果..运行我的查询在mysql.i把where语句之间paranthesis ..那个时候得到正确的结果 – robins