I have these two where
clauses to select data from table. I want to combine these two into one. When I added AND
, it doesn't give output. It works fine if I used it separately.... But I want two where
condition to work at same time
$this->db->where("(DATE_FORMAT(from_date,'%m') = '$m' AND DATE_FORMAT(from_date,'%Y') = '$y')OR (DATE_FORMAT(to_date,'%m') = '$m' AND DATE_FORMAT(to_date,'%Y') = '$y' )");
$this->db->where("resource","$e");
$this->db->order_by("status","desc");
Try this,
$where = "((DATE_FORMAT(from_date,'%m') = '$m' AND DATE_FORMAT(from_date,'%Y') = '$y') OR (DATE_FORMAT(to_date,'%m') = '$m' AND DATE_FORMAT(to_date,'%Y') = '$y')) AND 'resource' = '$e'";
$this->db->where($where);
$this->db->order_by("status","desc");