How to group field data?

前端 未结 2 1563

I have sql query to show data

\"SELECT
  `artikel`.`foto_naam`,
  `fotografer`.`id`,
  `fotografer`.`name_fotografer`,
  `customer`.`first_name`,
  `customer`.`l         


        
2条回答
  •  一个人的身影
    2021-01-24 22:47

    One thing you can do in mysql is to wrap you query with a group by and group_concat(). Something like this:

    SELECT
        name, 
        email, 
        group_concat(customer) AS customers, 
        group_concat(invoice_id) AS invoice_ids
    FROM
        (...query you already have..)
    GROUP BY
        name, email
    

    Result will look like something like this:

    name    email               customers           invoice_ids
    
    heko    heko@gmail.com      pae,edwin           15,16
    Lekto   lekto@gmail.com     edwin,risa,edwin    11,12,13
    

    PLZ SEE FIDDLE

提交回复
热议问题