This question has already been answered:

There are records with the same data, only one field is different: img

How to make a single query grouping by id, and in the second column to get all the values ​​separated by commas

Reported as a duplicate by Mike members, Community Spirit 26 Oct '16 at 12:59 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    Use the aggregate function GROUP_CONCAT()

     SELECT id, GROUP_CONCAT(name) FROM my_table GROUP BY id 
    • Before giving an answer to an elementary question, try for the author of the question to search for such answers on the site of 100,500 pieces, it makes no sense to produce more - Mike