oralce写法:
select WM_CONCAT(A.title) as citys from tmpcity A
sql server写法:
select stuff((select ','+A.title from tmpCity A FOR xml PATH('')), 1, 1, '') as citys
mysql写法:
select GROUP_CONCAT(A.title) as citys from tmpcity A; --默认的逗号分隔
select GROUP_CONCAT(A.title SEPARATOR ' ') as citys from tmpcity A; --用空格分隔
本文介绍了如何在不同类型的数据库中实现字段的聚合查询,包括Oracle、SQL Server及MySQL,并提供了具体的SQL实现方法。
1584

被折叠的 条评论
为什么被折叠?



