[英]GROUP_CONCAT() mysql returns limited characters
我要兩張桌子
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條以上的記錄時,名稱鍵僅提供有限數量的字符。 沒有完整的記錄。
我想小組比賽中會有局限性。
在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';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.