модель
Код: Выделить всё
$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();
Код: Выделить всё
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`