可以用來創建方案試圖從一類更新/更新插入到另一個
CREATE CLASS v1 EXTENDS v
CREATE CLASS v2 EXTENDS v
CREATE PROPERTY v1.p1 STRING
CREATE PROPERTY v1.p2 STRING
CREATE PROPERTY v1.p3 STRING
CREATE PROPERTY v2.p1 STRING (MANDATORY TRUE)
CREATE PROPERTY v2.p2 STRING (MANDATORY TRUE)
CREATE PROPERTY v2.p3 STRING
CREATE INDEX v2.p1 UNIQUE
INSERT INTO v1 (p1,p2,p3) VALUES ('a','b','c')
INSERT INTO v1 (p1,p2,p3) VALUES ('d','e','f')
INSERT INTO v1 (p1,p2,p3) VALUES ('h','i','j')
INSERT INTO v2 (p1,p2,p3) VALUES ('a','y','z')
和這些是以下中選擇的查詢的結果從
選擇下列V1
{
"result": [
{
"@type": "d",
"@rid": "#33:0",
"@version": 1,
"@class": "v1",
"p1": "a",
"p2": "b",
"p3": "c"
},
{
"@type": "d",
"@rid": "#34:0",
"@version": 1,
"@class": "v1",
"p1": "d",
"p2": "e",
"p3": "f"
},
{
"@type": "d",
"@rid": "#35:0",
"@version": 1,
"@class": "v1",
"p1": "h",
"p2": "i",
"p3": "j"
}
],
"notification": "Query executed in 0.011 sec. Returned 3 record(s)"
}
選擇V2
{
"result": [
{
"@type": "d",
"@rid": "#41:0",
"@version": 1,
"@class": "v2",
"p1": "a",
"p2": "y",
"p3": "z"
}
],
"notification": "Query executed in 0.013 sec. Returned 1 record(s)"
}
我已經嘗試了多個sql語句,嘗試將v1和v2的字段合併到近兩天,但無法找到答案。你可以告訴我要去的地方錯了
LET $t = SELECT FROM v1
UPDATE v2 SET (p1,p2) VALUES ($t.$current.p1, $t.$current.p2) UPSERT WHERE $current.p1 = $t.$current.p1
期望的結果將是V2有值「A,B,Z」和已添加了額外的兩個記錄,因爲他們在V1
更新當前記錄
所以,我只想澄清,你想擁有,在結束,包含「abv」「de」「hi」的v2? –
v2需要包含3條記錄 –
v2需要包含3條記錄。記錄1(a,b,z),記錄2(d,e,f),記錄3(h,i,j) –