How to hack MySQL GROUP_CONCAT to fetch a limited number of rows?

I’ve worked around this using SUBSTRING_INDEX.

For example:

SELECT SUBSTRING_INDEX(GROUP_CONCAT(Field1 SEPARATOR ','), ',', [# of elements to return])
FROM Table1;

Leave a Comment