“Sélectionnez une ligne Inclure la liste du tableau avec JOIN Two Table SQL” Réponses codées

Sélectionnez une ligne Inclure la liste du tableau avec JOIN Two Table SQL

SELECT e.aid, e.actors, a.act_names, e.benefactors, b.ben_names
FROM   eg_assoc e
, LATERAL (
   SELECT ARRAY( SELECT name
                 FROM   generate_subscripts(e.actors, 1) i
                 JOIN   eg_person p ON p.id = e.actors[i]
                 ORDER  BY i)
   ) a(act_names)
, LATERAL (
   SELECT ARRAY( SELECT name
                 FROM   generate_subscripts(e.benefactors, 1) i
                 JOIN   eg_person p ON p.id = e.benefactors[i]
                 ORDER  BY i)
   ) b(ben_names);
Arrogant Angelfish

Sélectionnez une ligne Inclure la liste du tableau avec la table de jointure SQL

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);
Arrogant Angelfish

Réponses similaires à “Sélectionnez une ligne Inclure la liste du tableau avec JOIN Two Table SQL”

Questions similaires à “Sélectionnez une ligne Inclure la liste du tableau avec JOIN Two Table SQL”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code