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
616 views
in Technique[技术] by (71.8m points)

sql - mysql group_concat not bringing entire data

I am using the following query and utilizing the group_concat function. However, at times the data in the answers column is being cut off; meaning I don't get the entire data, in the end it is just chopped off.

I suspect it might have something to do with the datatype....can it be casted to a bigger datatype? Currently the Other1 datatype is text

 select SiteName, 
case 
when group_concat(Other1) is not null 
  then  group_concat( cast(Other1 AS BLOB)) 
when group_concat(Other1) is null
  then  'No Response provided'
end
 'answers'
from disparities_community_partnerships
where QuarterId=2
group by SiteName
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer

SET [GLOBAL | SESSION] group_concat_max_len = val;

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

...