I have a query that looks like this:
SELECT
s.*,
array(
SELECT m.id
FROM swarm_machine sm
JOIN machine m
ON sm.machine_id = m.id
WHERE swarm_id = s.id
) as machines
FROM swarm s
WHERE group_id = 48
Instead of returning just the machine ids SELECT m.id, i would like to return all the columns in the row instead SELECT m.*. PostgreSQL doesn't seem to allow this, but I was hoping that the community could help be figure it out.
I can always do this with 2 queries, but if PostgreSQL can do it for me I'd rather avoid the round trip.
SQL Fiddle: http://sqlfiddle.com/#!17/d7481/1