select
group_concat(products_id
)
from zen_products_to_categories where categories_id=605
将分组上的结果用逗号“,”分隔并合并返回
select
CAST(group_concat(`products_id`) as char(100000)
)
as pids from zen_products_to_categories group by categories_id
将结果列格式转换
一不小心给试出来的,感觉挺有意思的赶紧记下
一下是mysql帮助文档中帮大家找出来的:
CAST(expr AS type), CONVERT(expr,type) , CONVERT(expr USING transcoding_name)
CAST() 和CONVERT() 函数可用来获取一个类型的值,并产生另一个类型的值。
这个类型 可以是以下值其中的 一个:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
BINARY 产生一个二进制字符串