我有两个表GROUP_CONCAT()的MySQL返回有限的字符
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
下面是我的查询:
$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条记录时,名称键只给出有限数量的字符。没有得到完整的记录。
我想组的concat会有限制。
“GROUP_CONCAT”的最大长度约为1024.您可以通过服务器变量更改此值。看到这里:http://stackoverflow.com/questions/2567000/mysql-and-group-concat-maximum-length –
检查'group_concat_max_len' https://dev.mysql.com/doc/refman/5.0/en/server -system-variables.html#sysvar_group_concat_max_len –
@pala_ yes你是对的我检查strlen($ name),它表示1024 – Butterfly