如何在cosmosdb中使用子查询来实现左连接?

nhjlsmyf  于 2021-07-24  发布在  Java
关注(0)|答案(2)|浏览(336)

在这里,我在left join中也使用了相同的文档:

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

在上述用例中,如果没有左连接,我如何实现这一点?

rta7y2nd

rta7y2nd1#

假设 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;
u1ehiz5o

u1ehiz5o2#

cosmos db目前只支持自连接。您可以参考此文档。左连接在cosmos db开发团队计划中,暂定于2020年下半年开始。您可以在此处跟踪此功能。

相关问题