Search code examples
mysqlgroup-concat

mysql GROUP_CONCAT with multiple columns


I want to do a group concat with multiple columns inside it. This is the query I have(I want to know if it is possible, and if not, what other way can I do this?:

select  group.groupname, 
        group_concat(machine.machinename,'--',machine.machineModel) 
    inner join etc....

Solution

  • You need to first concatenate those values and then do group_concat.

    select  group.groupname, 
            group_concat(machine.machinename||'--'||machine.machineModel)) 
        inner join etc....