How to Use GROUP_CONCAT in MySQL

Last updated July 24, 2026 · By the SaturnSQL team

GROUP_CONCAT collapses grouped rows into one delimited string, with optional DISTINCT, ORDER BY, and SEPARATOR. Results are silently truncated at group_concat_max_len (default 1024), so raise it for long lists.

SELECT customer_id,
       GROUP_CONCAT(DISTINCT product_name ORDER BY product_name SEPARATOR ', ') AS products
FROM order_items
GROUP BY customer_id;

Raise the length limit for the session

SET SESSION group_concat_max_len = 100000;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related MySQL guides

© 2026 Panda Capital Oy Ab. All rights reserved.