I have a problem joining two tables. In my first table, I want to retrieve 1 row for the time, and in the 2nd table I want to retrieve the table_number and table_sizes with both table having the same key which is the resto_id. But it seems to return repeating values for the time. I've tried using group_by but it didnt work out.
here's my model:
$this->db->where('resto_settings_time.resto_id',$id);
$this->db->select('op_time_start,op_time_end, table_number, table_size');
$this->db->from('resto_settings_time');
$this->db->join('resto_settings_table', 'resto_settings_time.resto_id = resto_settings_table.resto_id', 'left');
$query = $this->db->get();
return $query->result();
my Controller:
$data['rows'] = $this->process_resto_list->rsrv_details($id);
$this->load->view('sample',$data);
my view:
foreach ($rows as $row) {
echo $start= $row->op_time_start . br();
echo $end= $row->op_time_end . br();
echo $num = $row->table_number . br();
echo $size = $row->table_size . br();
}
And here is what it returns:
07:00:00 24:00:00 7 3 07:00:00 24:00:00 6 4
I would like 07:00:00 24:00:00 to repeat only once.. Please help me out, I'm really confused. Any help will be much appreciated. Thank you
我没有收到您的问题,但是要删除重复的数据,您必须按查询分组
$this->db->group_by()
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.