PostgreSQL
 sql >> Datenbank >  >> RDS >> PostgreSQL

Postgres - Fassen Sie zwei Spalten zu einem Element zusammen

SELECT user_id, array_agg((friend_id, confirmed)) as friends
FROM friend_map
WHERE user_id = 1
GROUP BY user_id

user_id |           array_agg            
--------+--------------------------------
      1 | {"(2,true)","(3,false)","(4,false)"}