【问题标题】:From String to Blob从字符串到 Blob
【发布时间】:2010-09-16 13:29:11
【问题描述】:

我正在尝试在 group_concat 命令中使用 concat_ws。使用查询,简化如下:

SELECT item.title, GROUP_CONCAT( CONCAT_WS(  ',', attachments.id, attachments.type,     attachments.name ) )  as attachments
FROM story AS item
LEFT OUTER JOIN story_attachment AS attachments ON item.id = attachments.item_id
GROUP BY item.id

我将附件列作为 Blob 类型。是否可以将其作为字符串而不是 Blob 获取?

【问题讨论】:

    标签: sql mysql blob


    【解决方案1】:

    您需要转换为字符..

    SELECT item.title, GROUP_CONCAT( CAST(CONCAT_WS(',', attachments.id, 
    attachments.type, attachments.name ) as CHAR ) ) as attachments 
    FROM story AS item 
    LEFT OUTER JOIN story_attachment AS attachments 
    ON item.id = attachments.item_id GROUP BY item.id
    

    【讨论】:

      【解决方案2】:

      虽然我怀疑 CAST 是合适的答案,但值得一提的是,我过去遇到过类似的事情,结果证明归结为奇怪/冲突的排序规则类型和字符集。

      【讨论】:

        猜你喜欢
        • 2016-03-22
        • 2018-01-09
        • 2019-01-29
        • 2015-02-07
        • 2021-02-09
        • 2020-06-17
        • 1970-01-01
        • 2019-01-13
        相关资源
        最近更新 更多