从String到Blob

时间:2008-10-10 15:58:35

标签: sql mysql blob

我正在尝试在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?

2 个答案:

答案 0 :(得分:2)

你需要扮演一个角色..

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

答案 1 :(得分:0)

虽然我怀疑CAST是一个合适的答案,但值得一提的是,我在过去遇到了类似的事情,结果发现是一个奇怪/冲突的校对类型和字符集。