How to merge rows and form multivalued attributes for a 2 column table in MySQL

Advertisements

I know this is terrible practice indeed, but I want to use the merged multivalued table for the GUI part of my program. Following is the thing I want.

raw table

to something like

multivalued merged table

Thanks in advance !!

>Solution :

Use GROUP_CONCAT for it:

select workerid, GROUP_CONCAT(worktype)
from t
group by workerid

Look at the fiddle here.

Leave a Reply Cancel reply