[英]Split value in single row to multiple rows with Postgresql
You could create an array and then use UNNEST():您可以创建一个数组,然后使用 UNNEST():
SELECT UNNEST(ARRAY[1,2,3]);
You are looking for Unpivot
, then you can try to use UNION ALL
您正在寻找Unpivot
,然后您可以尝试使用UNION ALL
select '1' column
UNION ALL
SELECT '2'
UNION ALL
SELECT '3'
or you can try to use JOIN LATERAL或者你可以尝试使用JOIN LATERAL
SELECT s.*
FROM test t
JOIN LATERAL (VALUES(t.a),(t.b),(t.c)) s(column) ON TRUE
I prefer to use a table function for that:我更喜欢为此使用表格 function :
SELECT CAST(i AS text) FROM generate_series(1, 3) AS i;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.