【发布时间】:2015-02-25 08:53:44
【问题描述】:
我有两个收藏。
LogData
[{
"SId": 10,
"NoOfDaya" : 9,
"Status" : 4
}
{
"SId": 11,
"NoOfDaya" : 8,
"Status" : 2
}]
OptData
[ {
"SId": 10,
"CId": 12,
"CreatedDate": ISO(24-10-2014)
}
{
"SId": 10,
"CId": 13,
"CreatedDate": ISO(24-10-2014)
}]
现在使用 mongoDB 我需要在表单中查找数据
select a.SPID,a.CreatedDate,CID=(MAX(a.CID)) from OptData a
Join LogData c on a.SID=c.SID where Status>2
group by a.SPID,a.CreatedDate
LogData 有 600 条记录,而 OPTData 有 9000 万条生产记录。我需要经常更新 LogData,这就是为什么它在单独的集合中。
- 请不要建议将数据保存在一个集合中。
- 这是同一个查询,我用不同的方法问Creating file in GridFs (MongoDb)
- 请不要建议无法在 mongoDB 中应用 Join。
【问题讨论】: