小编典典

mysql group_concat不带全部数据

sql

我正在使用以下查询并利用该group_concat功能。但是,有时answers列中的数据被截断。意思是我没有得到全部数据,最后只是被砍掉了。

我怀疑它可能与数据类型有关。…可以将其转换为更大的数据类型吗?当前Other1数据类型是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

阅读 165

收藏
2021-03-10

共1个答案

小编典典

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

结果将被截断为由group_concat_max_len系统变量指定的最大长度,该默认值的默认值为1024。尽管返回值的有效最大长度受max_allowed_pa​​cket的值限制,但可以将其设置为更高的值。在运行时更改group_concat_max_len的值的语法如下,其中val是无符号整数

SET [GLOBAL | SESSION] group_concat_max_len = val;
2021-03-10