【问题描述】
在采用了 group_concat 拼接的字符串 作为查询条件时,值与预期不符。
【分析】
通过比对 group_concat 拼接的字符串, 与 库中原有的字符串。得出结果,可能由于 group_concat 有长度限制 之类的导致 拼接的字符串被截断
【解决方案】
(1)GROUP_CONCAT有个最大长度的限制,超过最大长度就会被截断掉,你可以通过下面的语句获得长度:
SELECT @@global.group_concat_max_len;
show variables like "group_concat_max_len";
使用以下语句设置:
SET GLOBAL group_concat_max_len=102400;
SET SESSION group_concat_max_len=102400;
(2)在MySQL配置文件中my.conf或my.ini中添加:
#[mysqld]
group_concat_max_len=102400
(3)重启MySQL服务
参考链接: https://blog.csdn.net/qq_19668507/article/details/99855545