2つの配列からエレメントを選択
2つの配列を結合し、両方からエレメントを選択して、入力を作成するクエリーを作成します。
手順
タスクの結果
クエリーは次のようになります:
FROM order AS o
UNNEST o.items
JOIN customer AS c ON c.custid = o.custid
SELECT {
c.name,
c.rating,
o.orderno,
itemno
}
以下の結果が返されます:
[
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1001,
"itemno": 347
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1001,
"itemno": 193
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1002,
"itemno": 460
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1002,
"itemno": 680
},
{
"name": "B. Pitt",
"rating": null,
"orderno": 1003,
"itemno": 120
},
{
"name": "B. Pitt",
"rating": null,
"orderno": 1003,
"itemno": 460
},
{
"name": "J. Roberts",
"rating": 565,
"orderno": 1004,
"itemno": 680
},
{
"name": "J. Roberts",
"rating": 565,
"orderno": 1004,
"itemno": 195
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 460
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 347
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 780
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 375
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 680
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 120
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 460
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1007,
"itemno": 185
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1007,
"itemno": 680
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1008,
"itemno": 460
}
]