我有兩個表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