Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a length limit to group_concat or another reason why it would not work on a text field

First, here is the query:

SELECT GROUP_CONCAT(title) title, GROUP_CONCAT(description) description,
skill_id, count(*)

FROM jobs j
INNER JOIN job_feed_details d
ON j.id = d.job_id
JOIN jobs_skills js
ON j.id = js.job_id
    WHERE moderated = 1
    group by skill_id

Everything works as expected except the description field only returns one result, instead of a concatenation of all results. I suspect this is because the description is a text field, but I cannot find anything about why concatenation would not work with a text field.

Anyone know why this would not work?

like image 736
jisaacstone Avatar asked Mar 26 '11 20:03

jisaacstone


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 is the use of Group_concat?

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

The group_concat result length is limited(truncated) to the value of the group_concat_max_len system variable. The default value of this variable is 1024.

If you want change the value of the variable the syntax is:

SET [GLOBAL | SESSION] group_concat_max_len = val;

More info Mysql 5 docs

like image 176
CronosNull Avatar answered Oct 22 '22 21:10

CronosNull