One method is union all
:
select name, idaction_url as idaction
from t
union all
select name, idaction_name
from t
union all
select name, idaction_content_interaction
from t;
Not sure if it is better option but you can transform needed fields to array and then unnest it:
WITH dataset AS (
SELECT *
FROM (VALUES
('a', 10, 11),
('b', 20,21)) AS t (user_id, idaction_1, idaction_2))
SELECT user_id, idaction
FROM (
SELECT user_id, ARRAY[idaction_1, idaction_2] arr
FROM dataset)
CROSS JOIN UNNEST(arr) as tmp(idaction)
user_id | idaction |
---|---|
a | 10 |
a | 11 |
b | 20 |
b | 21 |
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.