Karunakar Karunakar - 1 year ago 74
MySQL Question

comma separated string of selected values in mysql

I want to convert selected values into a comma separated string in MySQL. My initial code is as follows:

SELECT id FROM table_level where parent_id=4;

Which produced:


My desired output would look like this:


Answer Source

Check this

SELECT GROUP_CONCAT(id)  FROM table_level where parent_id=4 group by parent_id;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download