Hi there,
I’m stucking with the join operation by using a property contained into an array of objects.
I have these documents:
{
"type": "project",
"id": "project-1",
"lines": [
{
"id": "line-1",
"name": "Name Line 1",
"length": 20.0
},
{
"id": "line-2",
"name": "Name Line 2",
"length": 24.0
}
]
}
{
"type": "section",
"id": "section-1",
"lineId": "line-1",
"name":"name-section01"
}
I would like to write a query which has this result:
{
"type": "project",
"id": "project-1",
"lineSections": [
{
"lienId": "line-1",
"lineName": "Name Line 1",
"lineLength": 20.0,
"sectionId": "section-1",
"sectionName": "name-section01"
},
{
"id": "line-2",
"name": "Name Line 2",
"length": 24.0
}
]
}
Here is my attempt, which returns an empty array
SELECT *
FROM `data` AS prj
LEFT JOIN `data` AS sct ON prj.lines[*].id = sct.id
WHERE prj.type = `project` AND sct.type = `section`
Can anyone give me an help?
Thank you.