📜  选择一行包含带有连接表的数组列表 SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:23.734000             🧑  作者: Mango

代码示例1
SELECT id, i.title AS item_title, t.tag_array
FROM   items      i
JOIN  (  -- or LEFT JOIN ?
   SELECT it.item_id AS id, array_agg(t.title) AS tag_array
   FROM   items_tags it
   JOIN   tags       t  ON t.id = it.tag_id
   GROUP  BY it.item_id
   ) t USING (id);