sql - 将 SQL 查询转换为等效的 mongodb 查询
问题描述
我需要你们帮助将 SQL 查询转换为 mongodb 查询。
这是我的查询:
select *
from DocumentDetails
where OldBatchDesc in (select top 1 OldBatchDesc
from DocumentDetails
where DocumentId = '2d0c4fef-21c8-4089-8e48-103055902741')
解决方案
所以,伙计们,我终于实现了。为未来的读者提供解决方案。我使用 Robo3t。
db.getCollection('documentdetails').aggregate([
{ "$match": {
"OldBatchDesc": {
"$in": db.getCollection('documentdetails').distinct("OldBatchDesc",{ "DocumentId": "2d0c4fef-21c8-4089-8e48-103055902741" })
}
}}
])
推荐阅读
- python - 异常:Java 网关进程在使用 pyspark 发送其端口号之前已退出
- kubernetes - 在 EKS 内的 ELK 盒子上记录活动监控
- c++ - 在预期错误的用户输入的情况下获得数字的平均值
- python - 在 Tkinter 上向 CSV 文件添加新信息时出现问题
- python - 如何将我现有的程序绑定到 Pulumi?
- python - 从没有索引的dict导入数据框
- java - 如何验证@RequestHeader在spring boot中是否为null?
- python - 逐渐添加 Kivy 小部件
- azure-aks - 如何将第二个 ACR 附加到我的 AKS 群集?
- javascript - 无论成功与否,如何在 $.post 之后运行 Javascript 代码?