將多行記錄轉化為一個字符串,用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;