GROUP_CONCT()mysql返回有限的字符


GROUP_CONCAT() mysql returns limited characters

我必须有两个表

tbl彩色库

id   name
1     test color

tbl彩色

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

以下是我的查询:

$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";

此查询将返回类似的结果

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

一切都很好,直到我的记录有限。当我在tblColors中有150条以上的记录时,名称键只提供有限数量的字符。没有得到完整的记录。

我想在小组赛中会有限制。

在mysql数据库中增加您的group_concat_max_len。默认情况下,它设置为1024。您可以使用查询进行更新

SET GLOBAL group_concat_max_len=100000

SET SESSION group_concat_max_len = 1000000;

检查group_concat_max_len的值,并根据需要增加它。

show variables like 'group_concat_max_len';