mysql函数 字符长度限制_MySQL中使用group_concat()函数数据字符过长报错的问题解决方法

select GROUP_CONCAT(uid) as uids,spread_uid from eb_user_spread where uid<>spread_uid GROUP BY spread_uid

使用GROUP_CONCAT 函数将字符串连接起来,数据量大的时候,会默认截取,导致字符串显示出来不全,处理方法:

方法1(需要管理员权限)
SHOW VARIABLES LIKE "group_concat_max_len"; #查询最大值
SET GLOBAL group_concat_max_len=102400;

SET SESSION group_concat_max_len=102400
方法2(这个是线上的,不可能轻易去改)
永久设置group_concat长度,需要修改my.cnf或my.ini文件,在文件中找到[mysqld] 在后面添加group_concat_max_len=102400,保存之后然后重启mysql即可
方法3(临时设置,在mysql客户端是一次性的,对于我正好可以用)

1、执行set group_concat_max_len=102400;

 

posted @ 2022-10-20 09:36  御世制人  阅读(254)  评论(0编辑  收藏  举报