在 PHPMYADMIN 中使用 group_concat 将显示结果为 [BLOB - 3B]
我有一个查询,它在整数字段上使用 mysql 的 GROUP_CONCAT。
我正在使用 PHPMYADMIN 来开发此查询。我的问题是,我得到的是 [BLOB - 3B],而不是显示连接字段的结果 1,2。
查询是
SELECT rec_id,GROUP_CONCAT(user_id)
FROM t1
GROUP BY rec_id
(两个字段都是无符号整数,都不是唯一的)
我应该添加什么才能看到实际结果?
I have a query which uses the GROUP_CONCAT of mysql on an integer field.
I am using PHPMYADMIN to develop this query. My problem that instead of showing 1,2 which is the result of the concatenated field, I get [BLOB - 3B].
Query is
SELECT rec_id,GROUP_CONCAT(user_id)
FROM t1
GROUP BY rec_id
(both fields are unsigned int, both are not unique)
What should I add to see the actual results?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
看起来 GROUP_CONCAT 期望该值是一个字符串。我刚刚遇到了同样的问题。通过将 int 列转换为字符串来解决这个问题,如下所示:
我想我会分享,以防您仍然遇到此问题。
Looks as though GROUP_CONCAT expects that value to be a string. I just ran into the same problem. Solved it by converting the int column to a string like so:
Figured I'd share in case you were still having an issue with this.
根据 MySQL 文档,
CAST(expr AS type)
是标准 SQL,因此应该优先使用。另外,您可以省略字符串长度。因此,我建议如下:According to the MySQL documentation,
CAST(expr AS type)
is standard SQL and should thus be perferred. Also, you may omit the string length. Therefore, I’d suggest the following:对我来说,这有帮助(在这个 博客文章):
在我的例子中,
GROUP_CONCAT
的参数是字符串,但该函数仍然生成 BLOB,但转换GROUP_CONCAT
的结果有效。For me, this helped (found it in this blog post):
In my case the parameter to
GROUP_CONCAT
was string but the function still resulted in a BLOB, but converting the result of theGROUP_CONCAT
worked.在查询结果的正上方(左侧)您将看到
+options
。按下并标记Just above the query result (to the left) you will see
+options
. Press it and mark您可以这样做:
如果 group_concat_max_len 大于 512,则查询将返回 byte[]。
但你可以传递一个字符串。
You can do this:
If group_concat_max_len is more than 512 the query will return byte[].
But you can pass to a string.
在最新的Phpmyadmin中
运行查询后,您将看到一些结果,然后点..,
因此只需单击选项(位于查询结果的顶部)
然后只需选择
单选按钮,默认为部分文本
然后按执行按钮,您将看到完整结果
In the latest Phpmyadmin
After running query, you will see some results and then dot ..
so just click on options (which is on top of the query result)
Then Just select
radio button, default is Partial texts
Then press Go button and you will see full result
如果您有权访问 phpMyAdmin 目录中的 config.inc.php 文件,那么
我认为最好的解决方案是将这一行:更改
为:
如果您有可用的 mysqli 扩展,请使用它。它更安全,更优化,并且默认情况下可以更好地处理 utf-8 的 BLOB 类型。您的 [BLOB] 条目应该开始显示为其值,而无需添加任何其他特殊配置选项。
If you have access to the
config.inc.php
file in the phpMyAdmin directory, thenI think the best solution is to change this line:
to this:
If you have the mysqli extension available, use it. It is more secure, a bit more optimized, and it handles the BLOB type of utf-8 better by default. Your [BLOB] entries should start showing up as their values without having to add in any other special configuration options.