My-Sql Group与concat结束

时间:2016-12-21 07:51:12

标签: mysql

我使用下面的查询来获取数据,但我得到了截断结果

SELECT group_concat(concat(`cl`.`payment_info`, '<=>', `cl`.`total_amount`) SEPARATOR '<==>') AS payment_info

Array
(
    [0] => Array
        (
            [payment_info] => [{"payment_date":"12\/12\/2016","payment_percentage":"30.00","payment_status"
:"Paid"},{"payment_date":"13\/12\/2016","payment_percentage":"20.00","payment_status":"Unpaid"},{"payment_date"
:"","payment_percentage":"","payment_status":"Unpaid"},{"payment_date":"","payment_percentage":"","payment_status"
:"Unpaid"},{"payment_date":"","payment_percentage":"","payment_status":"Unpaid"}]<=>0.00<==>[{"payment_date"
:"12\/12\/2016","payment_percentage":"50.00","payment_status":"Paid"},{"payment_date":"13\/12\/2016"
,"payment_percentage":"40.00","payment_status":"Unpaid"},{"payment_date":"","payment_percentage":"","payment_status"
:"Unpaid"},{"payment_date":"","payment_percentage":"","payment_status":"Unpaid"},{"payment_date":"","payment_percentage"
:"","payment_status":"Unpaid"}]<=>548.43<==>[{"payment_date":"12\/12\/2016","payment_percentage":"30
.00","payment_status":"Paid"},{"payment_date":"13\/12\/2016","payment_percentage":"20.00","payment_status"
:"Unpaid"},{"payment_date":"","payment_percentage":"","payment_status":"
        )

)

当数据量很大时我面临这个问题,否则这个查询工作正常,请告诉我哪里弄错了。

在付款信息中,json格式数据在保存时保存,金额保存。 payment_info数据类型是文本

1 个答案:

答案 0 :(得分:0)

您必须设置 group_concat_max_len 。默认长度为1024个字符。见手册信息

<强> group_concat_max_len

Description: Maximum length in bytes of the returned result for a GROUP_CONCAT() function.
Commandline: --group-concat-max-len=#
Scope: Global, Session
Dynamic: Yes
Data Type: numeric
Default Value: 1024
Range - 32-bit: 4 to 4294967295
Range - 64-bit: 4 to 18446744073709547520