select a row include list of array with join table sql

Solutions on MaxInterview for select a row include list of array with join table sql by the best coders in the world

showing results for - "select a row include list of array with join table sql"
Giada
09 Jan 2017
1SELECT id, i.title AS item_title, t.tag_array
2FROM   items      i
3JOIN  (  -- or LEFT JOIN ?
4   SELECT it.item_id AS id, array_agg(t.title) AS tag_array
5   FROM   items_tags it
6   JOIN   tags       t  ON t.id = it.tag_id
7   GROUP  BY it.item_id
8   ) t USING (id);
9