0

これで:

    $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);

order_status_history.new_status が間隔 (2<=order_status_history.new_status<=6) である select count(id) が必要です。単一の整数はありません。このSQLでこれをどのように作成しますか?

4

2 に答える 2

2

私が覚えているように、ネイティブSQLクエリのように、Whereステートメントを文字列として追加できます。これを試してください:

    $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');

これは稼働していますか ?

于 2013-03-05T09:15:41.840 に答える
2

あなたはこのことについてどう思いますか:

$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);
于 2013-03-05T09:16:06.200 に答える