Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MySQL, is it possible to get more than 1024 characters back from GROUP_CONCAT

Tags:

mysql

I have a query which returns the count of a status that needs some very complex work to calculate. The user wants to drill down into that list, and I thought the easiest way would be to get the ids using GROUP_CONCAT.

Unfortunately, the result from GROUP_CONCAT is being truncated to 1024 (?!) characters.

Is it possible to get more than 1024 characters, or am I going about this the wrong way?

like image 427
Drarok Avatar asked Aug 14 '09 14:08

Drarok


People also ask

Is there a length limit to Group_concat?

Show activity on this post. I'm using GROUP_CONCAT() in a MySQL query to convert multiple rows into a single string. However, the maximum length of the result of this function is 1024 characters.

What does Group_concat do in MySQL?

GROUP_CONCAT is a function which concatenates/merges the data from multiple rows into one field. It is a GROUP BY function which returns a string if the group contains at least 1 non-null value, if it does not, it returns a Null value.


1 Answers

You need to set group_concat_max_len to a higher value. This can be done on a session or global level. The following query sets the max length to 10,000 for the rest of the queries in that session:

SET SESSION group_concat_max_len = 10000; 

What you're running into is the group_concat default max of 1024.

like image 157
Eric Avatar answered Nov 09 '22 08:11

Eric