0

此 SQL 查询反复给我相同的值:

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

我得到的价值是:

{
"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"
    }
]}

我在工作表中为 resume_id = 1 添加了两行数据,但在奖励表中为 resume_id = 1 添加了 1 行数据

4

0 回答 0