dpf5207 2015-03-12 06:13
浏览 757
已采纳

如何通过执行group_by获取所有内容 - CodeIgniter

I am working in codeigniter my problem is i have a query in which i am performing group_by('content_id'), i need to display all the content of same content_id seperately but its showing content of only first row of that group. Pls help.

Below is my Model

public function get_content(){
        $this->db->select('*');
        $this->db->from('content');
        $this->db->order_by('content_id', 'ASC');
        $this->db->group_by('content_id');
        $query = $this->db->get();
        return $query->result();
    }
  • 写回答

1条回答 默认 最新

  • dongxian7194 2015-03-12 06:23
    关注

    GROUP_CONCAT is what you need.

    $this->db->select('GROUP_CONCAT(column_name separator ", ") as alias',FALSE) // FALSE to protect the backticks
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services