下载吧 - 绿色安全的游戏和软件下载中心

软件下载吧

当前位置:软件下载吧 > 技术开发 > 数据库 > PostgreSQL 字符串拆分与合并案例

PostgreSQL 字符串拆分与合并案例

时间:2024-02-14 10:20作者:下载吧人气:19

我就废话不多说了,大家还是直接看代码吧~

with person_name as (
select c.id,
array_to_string(array_agg(distinct p.c_name), ‘ , ‘) as p_name
from biz_notification_config c
join biz_notification_person p
on p.id =
any (string_to_array(c.persons, ‘,’)::int[])
group by c.id
),
group_name as (
select c.id,
array_to_string(array_agg(distinct g.c_name), ‘ , ‘) as g_name
from biz_notification_config c
join biz_notification_group g
on g.id = any (string_to_array(c.c_groups, ‘,’)::int[])
group by c.id
)
select config.*, person_name.p_name, group_name.g_name
from biz_notification_config config
left join person_name
on config.id = person_name.id
left join group_name
on config.id = group_name.id;

标签[db:关键字]

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

热门阅览

最新排行

公众号