This SQL query gives me same values repeatedly:
select json_object('id',basics.resume_id,
'work',JSON_ARRAYAGG(json_object('name', work.name, 'location', work.location,
'description', work.description, 'position', work.position, 'url', work.url,
'startDate', work.startDate, 'endDate', work.endDate, 'summary', work.summary,
'highlights', work.highlights, 'keywords', work.keywords)
),
'awards', JSON_ARRAYAGG(JSON_OBJECT(
'title', awards.title
)
)) from basics
left join work on basics.resume_id = work.resume_id
left join awards on basics.resume_id = awards.resume_id where basics.resume_id = 1
The value I get for it is:
{
"id":1,
"work":[
{
"url":"http://piedpiper.example.com",
"name":"Pied Piper3",
"endDate":"2014-12-01",
"summary":"Pied Piper is a multi-platform technology based on a proprietary universal compression algorithm that has consistently fielded high Weisman Scores™ that are not merely competitive, but approach the theoretical limit of lossless compression.",
"keywords":"Javascript, React",
"location":"Palo Alto, CA",
"position":"CEO/President",
"startDate":"2013-12-01",
"highlights":"Build an algorithm for artist to detect if their music was violating copy right infringement laws, Successfully won Techcrunch Disrupt, Optimized an algorithm that holds the current world record for Weisman Scores",
"description":"Awesome compression company"
},
{
"url":" bnvc ",
"name":"Pied Piper",
"endDate":"vb nsncd",
"summary":"bcbbv",
"keywords":"nbdcnbsvd",
"location":"nbdcnb",
"position":"m m",
"startDate":" vbn vb",
"highlights":"jhsfcf ",
"description":"mbvm"
}
],
"awards":[
{
"title":"Digital Compression Pioneer Award"
},
{
"title":"Digital Compression Pioneer Award"
}
]}
I have added two rows of data in work table for resume_id = 1, but only 1 row of data in awards table for resume_id = 1