Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从表中选择,其中子句为interval_Php_Mysql_Codeigniter - Fatal编程技术网

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间隔!