duanruanxian5028 2015-04-07 00:22
浏览 71
已采纳

GROUP_CONCAT()mysql返回有限的字符

I have to two tables

tblColorLibrary

id   name
1     test color

tblColors

id  libraryId  colorCode  name
1     1           #fff     Prime Color
2     1           #ddd     Secondry Color
3     1           #E2CFC7  Favorite Color

Below is my query:

$stmt ="SELECT a.id, a.isActive as isActive, a.name as title, GROUP_CONCAT(b.colorCode ) as colors, GROUP_CONCAT(b.name) as name FROM ".$this->tblLibrary." as a JOIN tblcolors as b ON a.id = b.libraryId GROUP BY a.id ORDER BY b.id ASC";

This query will return result like this

Array
(
    [0] => Array
        (
            [id] => 1
            [isActive] => Y
            [title] => test
            [colors] => #fff,#ddd,#E2CFC7
            [name] => Prime Color, Secondry Color, Favorite Color
        )

)

All goes fine till I have limited records. When I have above 150 records in tblColors, name key gives only limited number of characters. Not getting full records.

I guess there will be limitation in group concat.

  • 写回答

2条回答 默认 最新

  • drbii0359 2015-04-07 00:26
    关注

    Increase your group_concat_max_len at mysql database. by default it set to 1024. you can update it by using query

    SET GLOBAL group_concat_max_len=100000
    

    and

    SET SESSION group_concat_max_len = 1000000;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 QGC打开没有地图显示,离线地图也不显示,如何解决?
  • ¥20 Android Studio 的 webview 与访问网络存在的限制
  • ¥15 某帖子的数据集不清楚来源,求帮助
  • ¥50 tc358743xbg寄存器配置
  • ¥15 idea构建mod报错无效的源发行版项目链接,如何解决?
  • ¥15 springboot中的路径问题
  • ¥80 App Store Connect 中设置了订阅项目,Xcode 中预览可以正确显示价格,真机测试却无法显示
  • ¥15 MATLAB的PIV算法问题
  • ¥15 RflySim例程学习:matlab编译报错
  • ¥20 谁来给我解答一下疑惑
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部