Home > Blockchain >  how to join 2 rows in database
how to join 2 rows in database

Time:06-03

I ran into some problems while structuring my database, and I will ask questions.

i have a table in database

id id_study writer
1 1 writer1
2 1 writer2
3 2 writer3

how to combine 2 table rows to produce output like below

id id_study writer
1,2 1 writer1, writer2
3 2 writer3

CodePudding user response:

SELECT GROUP_CONCAT(id) as id, id_study,GROUP_CONCAT(Writer) as Writer
FROM TABLE
GROUP BY id_study;
  • Related