我有这两个where
子句从表中选择数据。我想将两者合并为一个。当我添加AND
时,它没有输出。如果我单独使用它,效果很好。...但是我想同时运行两个where
条件
$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");
答案 0 :(得分:0)
尝试一下
$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");