【问题标题】:Aggregation query from two tables来自两个表的聚合查询
【发布时间】:2014-01-06 10:40:46
【问题描述】:

我们有一个架构:

stores:
{_id , name}

getways: 
{_id, store_id }

txes:
{tx_id,getway_id}

一个store有很多getway,getway有很多txes。

我们需要特定商店的交易数量。

SQL:

SELECT count 
FROM   txes 
WHERE  getway_id IN (SELECT _id 
                     FROM   getways 
                     WHERE  store_id = xxxx) 

在mongo查询中怎么写?

我在 jaspersoft studio mongo 查询中编写了这个查询。

【问题讨论】:

  • 我不知道 jaspersoft 但是,MongoDB 还不支持服务器端子查询

标签: sql mongodb subquery


【解决方案1】:

我不认为 mongodb 支持关系子查询。您需要使用数据库引用(Manual References 或 DBRefs)来完成您的任务。

查看此链接。 http://docs.mongodb.org/manual/reference/database-references/

【讨论】:

  • 数据库引用完全是客户端,不支持在数据库中获取引用
猜你喜欢
  • 2011-06-02
  • 2016-03-25
  • 1970-01-01
  • 2013-11-22
  • 1970-01-01
  • 1970-01-01
  • 2016-12-13
  • 2019-05-06
  • 2021-08-28
相关资源
最近更新 更多