2

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

4

2 回答 2

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
于 2008-10-10T16:06:46.550 回答
0

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

于 2008-10-10T16:09:38.837 回答