I need to join 2 columns into only one as follows.
4 Answers
If the values are in one table then use cross join with lateral. It uses just one table scan.
SELECT v.*
FROM table, LATERAL (
VALUES
(follower_id )
, (followed_id) -- data types must be compatible
) v ("connections")
similar question: Select distinct on multiple columns
2 Comments
Juan Carlos Oropeza
How is this different than
UNION ?Radim Bača
@JuanCarlosOropeza I believe it uses just one table scan

UNION?