我使用 GROUP_CONCAT 来获得由逗号分割的结果( ,
),但是当我看到时, GRUP_CONCAT
仅返回 205 拆分的数字,但在数据库中有 2448 结果(不同 aid
)。这是我的查询:
SELECT GROUP_CONCAT(`aid`) As favoriti
FROM `z_web_favoriti`
WHERE `kup_id`='1' AND `pos_id`='571'
当我执行:
SELECT DISTINCT `aid`
FROM `z_web_favoriti`
WHERE `kup_id`='1' AND `pos_id`='571'
我得到以下结果:显示第 0 - 29 行(总共 2448 行,..)
任何人都有一些解决方案,为什么它不起作用?
我在stackoverflow上搜索过类似的问题,但我找不到它..
最佳答案
可能你已经超过GROUP_CONCAT最大长度。
The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer:
SET [GLOBAL | SESSION] group_concat_max_len = val;
关于MySQL GROUP_CONCAT 不返回所有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42508326/