您的位置:首页 > 博客中心 > 数据库 >

为什么 MySQL 中 GROUP_CONCAT 函数返回 BLOB 大对象类型?(Why GROUP_CONCAT returns BLOB?)

时间:2022-03-14 04:22

为什么 MySQL 中 GROUP_CONCAT 函数返回 BLOB 大对象类型?(Why GROUP_CONCAT returns BLOB?)

太阳火神的美丽人生 ()

本文遵循“”创作公用协议



相似的文章列于下方,

我的问题是 CONCAT(字段名, ‘‘),这个用法,就是为了将字段名所代表的数值字段转换成字符串结果。

那么,从以下三楼回复中,我们可以摘出:CAST(user_id AS CHAR)

用 CAST 函数来将某个字段的值转换成字符型。


问题出现的原因是,CONCAT 的函数计算结果以字节形式返回,就造成被误认为是 BLOB 二进制的大对象。

所以,转换成字符串时,慎用该函数,而使用 CAST 进行转换。


使用 WorkBench 这类工具时,会有一个设置选项,可以把 二进制或可变二进制返回结果当成非二进制的字符串来看待,这样这类工具执行类似SQL语句,返回的函数计算字段值就不会被当成 BLOB 看待,而是直接显示其字符串值了。


Last week, when using the 

Indeed, instead of getting my result as 
Because 
You simply need to:

  • Indeed, it wouldn’t be possible to change the value of a system variable on a shared hosting.
    It is actually a nice trick to convert the column value to a string ! 技术分享

  • SELECT rec_id, GROUP_CONCAT(CAST(user_id AS CHAR))
    FROM t1
    GROUP BY rec_id

  • I found a problem with your CAST on MySQL

    when i have INT and i Gdo this
    SELECT rec_id, GROUP_CONCAT(CAST(user_id AS CHAR))
    FROM t1
    GROUP BY rec_id

    then i have always only 1 char space for the int value , this may work for 0-9 but not when your INT grow 技术分享

    for me it was fine to CAST as CHAR(7) to hold the
    biggest value 9999999 value from my INT:)

    SELECT rec_id, GROUP_CONCAT(CAST(user_id AS CHAR(7)))
    FROM t1
    GROUP BY rec_id








热门排行

今日推荐

热门手游