postgresql将多条记录结果合并为一个字符串,并加入分隔符
将多行记录转化为一个字符串,用array_to_string内置函数即可!
select array_to_string(array(
select distinct name from tab where 1=1
),‘–>’) as strs;
将一个字符串转化为多行记录,用regexp_splite_to_table即可!
select regexp_splite_to_table(‘asd,qwe,qeq,ere,fds,ert’,‘,’) as id;
分割之后再转化为整数
select cast( regexp_splite_to_table(‘1,2,3,4,5,6’,‘,’) as integer) as id;
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交