Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

mysql - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...