简体   繁体   中英

Group result in codeigniter query

I have table structure like this

id  agent_id ticket_number  booked_date 
1   1   ETS716B0PT10246 27 -Jan-2016    
2   1   ETS611B0PT10247 27-Jan-2016 
3   1   ETS479B0PT10248 27 -Jan-2016    
4   1   ETS414B0PT10291 26 -Jan-2016    
5   1   ETS730B0PT10391 26 -Jan-2016    
6   1   ETS982B0PT10396 26 -Jan-2016    
7   1   ETS515B0PT10397 26 Jan 2016 

From this i want to display ticket_number for each booked_date for a particular agent_id like this

27-Jan-2016 
  ETS716B0PT10246
  ETS730B0PT10391   
26 Jan 2016 
  ETS730B0PT10391
  ETS515B0PT10397

But i don't know how to accomplish this task

Here is my basic query

$this->db->where('agent_id', $id);
        $query = $this->db->get('spm_agent_tickets');        
        return $query->result_array(); 

使用GROUP BY子句?

$this->db->group_by('booked_date`);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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