MySQL 在 PHPMYADMIN 中使用 group_concat 将结果显示为 [BLOB - 3B]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2133936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using group_concat in PHPMYADMIN will show the result as [BLOB - 3B]
提问by Itay Moav -Malimovka
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].
我有一个查询,它在整数字段上使用 mysql 的 GROUP_CONCAT。
我正在使用 PHPMYADMIN 来开发这个查询。我的问题不是显示 1,2 这是连接字段的结果,而是得到 [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?
我应该添加什么才能看到实际结果?
采纳答案by Itay Moav -Malimovka
Just above the query result (to the left) you will see +options
. Press it and mark
在查询结果的正上方(左侧),您将看到+options
。按下并标记
Show BLOB contents
显示 BLOB 内容
回答by munch
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:
看起来好像 GROUP_CONCAT 期望该值是一个字符串。我刚刚遇到了同样的问题。通过将 int 列转换为字符串来解决它,如下所示:
SELECT rec_id,GROUP_CONCAT(CONVERT(user_id, CHAR(8)))
FROM t1
GROUP BY rec_id
Figured I'd share in case you were still having an issue with this.
想我会分享以防万一你仍然有这个问题。
回答by scy
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:
根据 MySQL 文档,CAST(expr AS type)
是标准 SQL,因此应该优先考虑。此外,您可以省略字符串长度。因此,我建议如下:
SELECT rec_id, GROUP_CONCAT(CAST(user_id AS CHAR))
FROM t1
GROUP BY rec_id
回答by Janne
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 the GROUP_CONCAT
worked.
在我的情况下,参数 toGROUP_CONCAT
是字符串,但该函数仍然导致 BLOB,但转换了GROUP_CONCAT
工作的结果。
CONVERT(GROUP_CONCAT(user_id) USING 'utf8')
回答by Joe
You can do this:
你可以这样做:
set session group_concat_max_len = 512;
If group_concat_max_len is more than 512 the query will return byte[]. But you can pass to a string.
如果 group_concat_max_len 大于 512,则查询将返回 byte[]。但是你可以传递给一个字符串。
System.Text.Encoding.Default.GetString((byte[])DataTable.Rows[0][0]);
回答by Devsi Odedra
In the latest Phpmyadmin
在最新的 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
然后只需选择
Full texts
全文
radio button, default is Partial texts
单选按钮,默认为部分文本
Then press Gobutton and you will see full result
然后按Go按钮,你会看到完整的结果
回答by cwd
If you have access to the config.inc.php
file in the phpMyAdmin directory, then
I think the best solution is to change this line:
如果您可以访问config.inc.php
phpMyAdmin 目录中的文件,那么我认为最好的解决方案是更改这一行:
$cfg['Servers'][$i]['extension'] = 'mysql';
to this:
对此:
$cfg['Servers'][$i]['extension'] = 'mysqli';
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.
如果您有可用的 mysqli 扩展,请使用它。它更安全,更优化,默认情况下可以更好地处理 utf-8 的 BLOB 类型。您的 [BLOB] 条目应该开始显示为它们的值,而无需添加任何其他特殊配置选项。