Php 从表中选择,其中子句为interval
在这方面:Php 从表中选择,其中子句为interval,php,mysql,codeigniter,Php,Mysql,Codeigniter,在这方面: $this->db->select('count(o.id)'); $this->db->from('orders o'); $this->db->join('order_status_history', 'o.id = order_status_history.order_id'); $this->db->where("(order_status_
$this->db->select('count(o.id)');
$this->db->from('orders o');
$this->db->join('order_status_history', 'o.id = order_status_history.order_id');
$this->db->where("(order_status_history.in_dts)::date ='" .$reportDay. "'");
$this->db->where('order_status_history.new_status ' , 6);
我想要选择count(id)where order_status_history.new_status是一个间隔,例如(2),因为我记得您可以将where语句添加为字符串,就像在本机sql查询中一样。 请试试这个:
$this->db->select('count(o.id)');
$this->db->from('orders o');
$this->db->join('order_status_history', 'o.id = order_status_history.order_id');
$this->db->where("(order_status_history.in_dts)::date ='" .$reportDay. "'");
$this->db->where('order_status_history.new_status BETWEEN 2 AND 6');
这是否有效?我记得您可以将Where语句作为字符串添加,就像在本机sql查询中一样。 请试试这个:
$this->db->select('count(o.id)');
$this->db->from('orders o');
$this->db->join('order_status_history', 'o.id = order_status_history.order_id');
$this->db->where("(order_status_history.in_dts)::date ='" .$reportDay. "'");
$this->db->where('order_status_history.new_status BETWEEN 2 AND 6');
这有效吗?您对此有何看法:
$this->db->select('count(o.id)');
$this->db->from('orders as o');
$this->db->join('order_status_history', 'o.id = order_status_history.order_id');
$this->db->where("(order_status_history.in_dts)::date ='" .$reportDay. "'");
$this->db->where_between('order_status_history.new_status ',2 , 6);
您对此有何看法:
$this->db->select('count(o.id)');
$this->db->from('orders as o');
$this->db->join('order_status_history', 'o.id = order_status_history.order_id');
$this->db->where("(order_status_history.in_dts)::date ='" .$reportDay. "'");
$this->db->where_between('order_status_history.new_status ',2 , 6);
使用where\u-between引入id间隔!使用where\u-between引入id间隔!