Couchbase N1QL使用子查询更新文档
我正在尝试对一个“国家”文档进行非规范化,其中“regionName”字段对应于另一个“Region”文档的“name”。我的N1QL查询如下所示,但它不起作用Couchbase N1QL使用子查询更新文档,couchbase,n1ql,Couchbase,N1ql,我正在尝试对一个“国家”文档进行非规范化,其中“regionName”字段对应于另一个“Region”文档的“name”。我的N1QL查询如下所示,但它不起作用 update test as t1 set regionName = ( select raw name from test as t2 where `_class`="Region" ) where `_class`="Country" and t1.regionCode=t2.code RETURNING *; 有什么帮助吗?N
update test as t1 set regionName = (
select raw name from test as t2 where `_class`="Region"
) where `_class`="Country" and t1.regionCode=t2.code RETURNING *;
有什么帮助吗?N1QL没有更新联接。不能在UPDATE WHERE子句中使用SET子句子查询源 使用合并
MERGE test AS m
USING test AS s
ON s.`_class`="Region" AND m.`_class`="Country" AND m.regionCode=s.code
WHEN MATCHED THEN m.regionName = s.name;
CB 6.0
MERGE test AS m
USING (SELECT META(c).id, r.name
FROM test AS r
JOIN test AS c
ON r.`_class`="Region" AND c.`_class`="Country"
AND r.regionCode = c.code) AS s
ON KEY s.id
WHEN MATCHED THEN m.regionName = s.name;