如何通过codeigniter中的同一列获取多行

ds97pgxw  于 2021-06-23  发布在  Mysql
关注(0)|答案(1)|浏览(330)

我试图通过同一列获取多行。我使用having子句,按顺序按所有内容分组,但它仍然只返回一行。

function slots($condition){
    $this->db->select('slot_id');
    $this->db->from('mn_date_slot');
    $this->db->where('journey_date',$condition);
    $this->db->group_by('journey_date');
    $this->db->order_by('slot_id','desc');
    return $this->db->get()->result_array();
    }

我想从旅程日期相同的4行中获取插槽id。

2sbarzqh

2sbarzqh1#

如果要获取行程日期相同的所有记录,则需要删除groupby选项。使用下列函数

function slots($condition){
    $this->db->select('slot_id');
    $this->db->from('mn_date_slot');
    $this->db->where('journey_date',$condition);
    $this->db->order_by('slot_id','desc');
    return $this->db->get()->result_array();
}

相关问题