gpt4 book ai didi

MYSQL CONCAT 最大长度

转载 作者:行者123 更新时间:2023-11-29 23:36:23 25 4
gpt4 key购买 nike

关注此帖子:POST ABOUT CONCAT我的问题是我有很多行 CONCAT 到一行中。例如,如果我有 10 行,字符串大约有 50 个字符,我的查询将只显示其中的 6-7 行或类似的内容。我在堆栈和谷歌中搜索,发现我可以通过命令更改 CONCAT 最大长度:SET group_concat_max_len := @@max_allowed_pa​​cket。我做错了什么?

编辑:当我 SHOW VARIABLES LIKE 'group_concat_max_len' 时,它显示了 1024。Mysql 版本 5.0.96-log。表类型:MyISAM。看起来它没有任何限制,我尝试选择具有 2000 个字符的简单 varchar,它看起来不错。我有 3 个表:第一个 - 带有 ItemID 的项目,第二个 - 带有 ItemID 和 DescriptionID 的描述包,第三个带有 DescriptionID 的描述。

Select
DISTINCT Item.ItemID as item
,GROUP_CONCAT(Description.DescriptionID) AS description
From Item
LEFT OUTER JOIN descriptionpack
on Item.ItemID=descriptionpack.ItemID
LEFT OUTER JOIN description
on descriptionpack.descriptionID=description.descriptionID
GROUP BY item

编辑2:我想我发现了问题,我向我的提供商说了我的问题,他们回答了我:

I reviewed your question with our hosting team. You wouldn't be able to change the global settings for that and other variables. However, you should be able to set that variable on a per session basis by setting it first, before other queries. Hope that helps.

所以现在的问题是,如何做到这一点。

最佳答案

大概您使用的是 GROUP_CONCAT(),而不是简单的 CONCAT()

group_concat_max_len 的默认值为 1024,如果您要构建大的长连接,这是一个相当小的限制。

要更改它,请使用此命令。我已将本示例中的长度设置为 100,000。您可以将其设置为您需要的任何内容。

 SET SESSION group_concat_max_len = 100000;

max_allowed_pa​​cket 的通常值为 1 MB,这可能超出您的需要。

group_concat_max_len itself has an effectively unlimited size 。它仅受平台的无符号字长限制:32 位平台上为 2^32-1,64 位平台上为 2^64-1。

如果这对于您的应用程序来说仍然不够,那么是时候接受 @eggyal 的建议并重新考虑您的方法了。

关于MYSQL CONCAT 最大长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26357834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com