MYSQL中group_concat
1、修改MYSQL中group_concat的限制(默认1024)
(1)永久修改
修改mysql的配置文件:
?C:\ProgramData\MySQL\MySQL Server 5.6\my.ini【正确位置】
C:\Program Files\MySQL\MySQL Server 5.6\my-default.ini【我一开始修改的错误位置!】
在最后一行添加:
group_concat_max_len = 102400 #你要的最大长度,也可以设置为-1,表示最大值(4294967295)
重启mysql服务
参考:
https://blog.csdn.net/ssxueyi/article/details/107733664
(2)临时修改(重启mysql服务前有用)
临时解决方案,执行以下sql语句:
SET GLOBAL group_concat_max_len=102400;【仅这句没用】
SET SESSION group_concat_max_len=102400;【这句有用】
(3)执行指令有用,但是修改my-default.ini没用,搞半天是找错位置了。
如何查看mysql的位置,参考:
https://zhuanlan.zhihu.com/p/181675602
2、mysql中concat 和 group_concat()的用法
前者是连接不同字段,后者是连接不同记录的同一个字段
select group_concat(id) as ids, group_concat(name) as exp from saml_type WHERE path='fs/namei.c' and level=2 and project=6
参考:
https://www.php.cn/mysql-tutorials-407074.html