繁体   English   中英

选择所有行,分组依据

[英]Select All Rows, Group By

在使用Codeigniter 3时,我试图从表“ X”中选择所有记录,同时尝试按列“ Y”对它们进行分组,如下所示:

$this->db->select();
$this->db->from("X");
$this->db->where(array('is_active' => 1));
$this->db->group_by('Y');

但是,这只为每个组检索一条记录。...任何帮助都将非常有用! 谢谢!

使用以下模式:

    $this->db->select('*');
    $this->db->from('X');
    $this->db->where('is_active', 1);
    $this->db->group_by('Y');
    $query_result = $this->db->get();
    $result = $query_result->result();
    return $result;

使用$ this-> db-> get()-> result_array()并将其分配给变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM