Search code examples
mysqlsqlgroup-bygroup-concat

Limit in the number of aggregated characters after running GROUP_CONCAT in SQL


I am using GROUP_CONCAT in my query to collect some IDs. Imagine I have two columns as follow:

user_id
item

The code looks like this:

SELECT user_id, GROUP_CONCAT(item) AS all_items_by_user
FROM table
GROUP BY user_id

However, I noticed that the all_items_by_user column can accommodate up to a certain number of characters in each cell. This limit is around 1100 in my case, whereas I expect at least 10 times more. I wondered whether there is any way to increase this limit? Thank you.


Solution

  • This is controlled by group_concat_max_len, a system variable.

    The documentation describes how to change the value and what it really means.