PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Trova tutte le partite per una determinata squadra in PostgreSQL

SELECT t.uuid, t.player_1_uuid, t.player_2_uuid, array_agg(m.uuid) as "match_uuids"
FROM teams t JOIN matches m ON t.uuid IN (m.team_a_uuid, m.team_b_uuid)
GROUP BY t.uuid;