原文链接:https://blog.csdn.net/a1102325298/article/details/80783525
group_concat用法
默认用法
select group_concat(vaccine_name) as dogVaccineName from t_vaccine where id in(select vaccine_id from t_dog_vaccine where dog_id = 1)
1
group_concat拼接时默认的分隔符是’,’
,如果我们想改变这个分隔符可以这样做。
REPLACE(group_concat(vaccine_name),',','
这里填写你所想换的分隔符’)
比如我想把默认的,换成;
select REPLACE(group_concat(vaccine_name),',',';') as dogVaccineName from t_vaccine where id in(select vaccine_id from t_dog_vaccine
自己写的
ti.tag_name,
ti.sex,
ti.`status`,
ti.create_time,
group_concat(ac.category_name) as categoryName,
group_concat(tac.category_id) as categoryId
from
tags_info ti
left join tags_activity_category tac on tac.tag_id = ti.tag_id
left join activity_category ac on ac.category_id = tac.category_id
GROUP BY ti.tag_name