使用函数group_concat(x,y),会返回一个字符串,该字符串会连接所有非NULL的x,使用符号y进行分割。如果忽略y参数,在连接时会使用分隔符","。
with p as(
select distinct(akas.title) as dubbed from akas
inner join titles on titles.title_id = akas.title_id
where primary_title = "House of the Dragon" and type = "tvSeries"
order by title
)
select group_concat(dubbed,",") from p;
以上代码是将p中的结果拼接在一起,使用", "分割开来,返回一个字符串。
如图所示,将查询到的结果拼接在了一起。