首页 > 其他分享 >PG把多条记录合并成字符串,用逗号分隔

PG把多条记录合并成字符串,用逗号分隔

时间:2023-02-18 18:11:55浏览次数:40  
标签:分隔 103001 103002 逗号 HD PG quote array select

select array_to_string(
  array(select quote_literal("HD_Code") from "public"."Hosp_Dept" where "HD_Code" in ('103001','103002','103') and "HD_SFMJ" is True), ';'
) as strs;
--------quote_literal
'103002';'103001'4

select array_to_string(
  array(select quote_ident("HD_Code") from "public"."Hosp_Dept" where "HD_Code" in ('103001','103002','103') and  "HD_SFMJ" is True), ','
) as strs;
--------quote_ident
"103002","103001"

 

 

标签:分隔,103001,103002,逗号,HD,PG,quote,array,select
From: https://www.cnblogs.com/usegear/p/17133226.html

相关文章