sql >> Database >  >> RDS >> Mysql

Query voegt alles samen in één rij in plaats van in afzonderlijke rijen

U moet group by . toevoegen clausule

 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



  1. Mysql count vs mysql SELECT, welke is sneller?

  2. cursor.execute(INSERT INTO im_entry.test (+entrym+) WAARDEN ('+p+');)

  3. MySQL wanneer kan ik HASH gebruiken in plaats van BTREE

  4. Hoe controleer ik of een waarde al bestaat om duplicaten te voorkomen?