这里我在左联接中也使用相同的文档:
select A.a,A.b,C.c
from Inventory A left join
(select B.a as id,B.a*100 as c
from Inventory B
where condition1 and condition2
) as C
on C.id
on A.a
在上面的用例中,如果没有左联接,我如何实现这一点?
Cosmos DB目前只支持自加入。您可以参考本文档。左加入是Cosmos DB开发团队的计划,也是2020年下半年的暂定开始。你可以在这里跟踪这个功能。
假设on C.id on A.a
是一个拼写错误,并且实际上是on C.id = A.a
:
select a.a, a.b, c.c
from inventory a
left join
(
select b.a as id, b.a * 100 as c
from inventory b
where condition1 and condition2
) as c on c.id = a.a;
等于
select a.a, a.b,
(
select b.a * 100
from inventory b
where condition1 and condition2
and b.a = a.a
) as c
from inventory a;