Search
 
SCRIPT & CODE EXAMPLE
 

SQL

nodejs sql get one to many relationship as array

-- use json_agg

SELECT i.id as interview_id, i.board, i.time_taken, i.notes, i.interview_date, 
       u.id as user_id, u.first_name, u.last_name, u.state, u.district, u.optional, 
       j.name as job, 
       json_agg(json_build_object('question', q.question, 'answer', q.answer, 'member', q."member", 'order', q."order")) as questions
FROM interview i LEFT JOIN
     question q
     ON q.interview_id = i.id JOIN
     users u
     ON i.user_id = u.id JOIN
     user_jobs uj
     ON uj.user_id = u.id JOIN
     job j
     ON uj.job_id = j.id
GROUP BY u.id, i.id, j.name
Comment

PREVIOUS NEXT
Code Example
Sql :: how to connect pgadmin with excel 
Sql :: big query add table rows to another table 
Sql :: distinct 
Sql :: mysql extract number from string 
Sql :: read_sql mysql 
Sql :: sql to c# linq converter online 
Sql :: How to write triggers to increment or decrement the number of employees 
Sql :: sqlserver: reverse like search 
Sql :: sql server 2016 iso 
Sql :: umgebungsvariable setzen für mysql 8 
Sql :: compare strings lexicographically in sql 
Sql :: closure in sql 
Sql :: <sql:datasource var="Snapsho" 
Sql :: hacer un programa en python ingresar números enteros determine el maximo 
Sql :: liquibase default-schema in sql 
Sql :: sql developer format sql 
Sql :: mysql configuration file storage location 
Sql :: sum over partition by postgresql 
Sql :: Update rows in SQL that retain the old value 
Sql :: sql select rows between 1000 and 2000 
Sql :: error access to system table innodb is rejected 
Sql :: apache2 ssl error 
Sql :: sql count and addition by day 
Sql :: mysql update set 
Sql :: oracle select partition 
Sql :: postgresql allow remote connections 
Sql :: why do we need data structure in sql 
Sql :: mysql insert into select transaction c# 
Csharp :: c# change label forecolor code 
Csharp :: net core get remote ip 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =