MySQL has a group function group_concat () :
SELECT group_concat(some_column) FROM mytable;
some_column all some_column values from a table joined by commas.
Caution: Beware that the result is limited to the group_concat_max_len system variable, which defaults to 1024 bytes! To avoid hitting this wall, you must complete this before running the request:
SET SESSION group_concat_max_len = 65536;
Or more, depending on how many expected results. But this value cannot be greater than max_allowed_packet
intgr source share