Quiere unir dos filas en una usando MySQL group_concat

Quiero fusionar 2 filas como una usando la consulta group_concat mysql

 $query = $this->db->select('trt.day, group_concat(trt.open_time, trt.close_time)') ->from('tbl_restaurant_timing as trt') ->where('trt.restaurant_id', $restaurant_id, FALSE) ->group_by('trt.day') ->get(); 

He intentado con el anterior pero proporciona algún otro resultado como el siguiente

 Array ( [0] => Array ( [day] => Fri [group_concat(trt.open_time, trt.close_time)] => 18:0023:00,10:0015:00 ) [1] => Array ( [day] => Mon [group_concat(trt.open_time, trt.close_time)] => 10:0015:00,18:0023:00 ) [2] => Array ( [day] => Sat [group_concat(trt.open_time, trt.close_time)] => 18:0023:00,10:0015:00 ) [3] => Array ( [day] => Sun [group_concat(trt.open_time, trt.close_time)] => 10:0015:00,18:0023:00 ) [4] => Array ( [day] => Thu [group_concat(trt.open_time, trt.close_time)] => 10:0015:00,18:0023:00 ) [5] => Array ( [day] => Tue [group_concat(trt.open_time, trt.close_time)] => 18:0023:00,10:0015:00 ) [6] => Array ( [day] => Wed [group_concat(trt.open_time, trt.close_time)] => 18:0023:00,10:0015:00 ) ) 

Aquí puede ver que la segunda ranura es la primera en algunas filas, lo que es incorrecto.

enter image description here

Esta mi mesa quiero resultado en la tabla php como a continuación

enter image description here

Entonces, comprueba dónde estoy equivocado. Gracias

Solutions Collecting From Web of "Quiere unir dos filas en una usando MySQL group_concat"

Encuentre las soluciones mencionadas a continuación, Operación larga de bits, pero creo que esto lo ayudará.

 SELECT trt.id, trt.day, (SELECT CONCAT_WS('-',open_time, close_time) from tbl_restaurant_timing trt1 WHERE trt1.day = trt.day ORDER BY trt1.id ASC LIMIT 1) as first_slot, (SELECT CONCAT_WS('-',open_time, close_time) from tbl_restaurant_timing trt1 WHERE trt1.day = trt.day ORDER BY trt1.id DESC LIMIT 1) as second_slot FROM tbl_restaurant_timing trt WHERE trt.restaurant_id = 1 GROUP BY trt.day ORDER BY id; 

Datos de tabla

 +----+----------------+-----------+-----------+------------+ | id | restaurant_id | day | open_time | close_time | +----+----------------+-----------+-----------+------------+ | 1 | 1 | Monday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 2 | 1 | Monday | 18:00 | 23:50 | +----+----------------+-----------+-----------+------------+ | 3 | 1 | Tuesday | 09:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 4 | 1 | Tuesday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ | 6 | 1 | Wednesday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 7 | 1 | Wednesday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ | 8 | 1 | Thursday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 9 | 1 | Thursday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ | 13 | 1 | Friday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 14 | 1 | Friday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ | 15 | 1 | Saturday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 16 | 1 | Saturday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ | 17 | 1 | Sunday | 10:00 | 15:00 | +----+----------------+-----------+-----------+------------+ | 18 | 1 | Sunday | 18:00 | 23:00 | +----+----------------+-----------+-----------+------------+ 

Resultado

 +----+-----------+-------------+-------------+ | id | day | first_slot | second_slot | +----+-----------+-------------+-------------+ | 1 | Monday | 10:00-15:00 | 18:00-23:50 | +----+-----------+-------------+-------------+ | 3 | Tuesday | 09:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ | 6 | Wednesday | 10:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ | 8 | Thursday | 10:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ | 13 | Friday | 10:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ | 15 | Saturday | 10:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ | 17 | Sunday | 10:00-15:00 | 18:00-23:00 | +----+-----------+-------------+-------------+ 

Avísame si no funciona.