Search
 
SCRIPT & CODE EXAMPLE
 

SQL

select a row include list of array with join table 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);
Comment

select a row include list of array with 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);
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql extract number from string 
Sql :: how to fix mysql stop unexpectedly 
Sql :: mysql dump everythign 
Sql :: How to fix a collation conflict in a SQL Server query 
Sql :: show specific partition hive query 
Sql :: how to get data from 2 database 
Sql :: mysql select top 2 
Sql :: mysql edit trigger 
Sql :: umgebungsvariable setzen für mysql 8 
Sql :: postgresql regular expression special characters 
Sql :: show database size or specific database table size 
Sql :: create more than 1 tables with references to each other in sqlite3 
Sql :: install phpmyadmin pma 
Sql :: oracle table change tablespace lob column 
Sql :: window function to forward fill 
Sql :: employee sample data mysql 
Sql :: linked server delete openquery 
Sql :: hive batch drop table 
Sql :: ring MySQL Create Database 
Sql :: best practive to pass multiple table to stored procedure in sql server 
Sql :: export all stored procedures to .sql files 
Sql :: calculations on columns sql 
Sql :: nosql databases 
Sql :: connect to remote mysql server 
Sql :: java.sql.sqlexception: access denied for user 
Sql :: bulk insert sql query syntax 
Sql :: ssms keyboard shortcuts 
Csharp :: guid.empty 
Csharp :: unity rotation between 2 points 
Csharp :: c# getasynckeystate mouse 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =