Mysql
 sql >> Database >  >> RDS >> Mysql

Query concatena tutto in una riga anziché in righe separate

Devi aggiungere group by clausola

 SELECT o.outfit_id, o.creation_date,
           GROUP_CONCAT(i.manufacturer_product_id ORDER BY i.manufacturer_product_id) as manufacturer_product_ids,
           GROUP_CONCAT(i.manufacturer_product_id ORDER BY i.manufacturer_product_id SEPARATOR ';') as manufacturer_product_ids_sep
    FROM outfits o INNER JOIN
         items_in_outfit io
         ON o.outfit_id = io.outfit_id JOIN
         items i
         ON io.item_id = i.item_id JOIN
         customer c
         ON o.cus_id = c.cus_id 
    WHERE c.driver_id = 2463
    group by o.outfit_id,o.creation_date
    ORDER BY o.creation_date