【发布时间】:2021-03-09 09:18:29
【问题描述】:
任何人都可以将 SQL 查询转换为 mongo 查询吗::
select customerId
from CustomerInfo
where customerId not in (select customerId
from CustomerInfo
where channel = 'A');
在这里,我想查找不存在频道“A”的 customerId。
【问题讨论】:
-
为什么不
select customerId FROM CustomerInfo WHERE channel <> 'A'? -
它也适用于 SQL。但我想要 mongo 查询。
-
应该是
db.CustomerInfo.find({channel: {$ne: "A"}}, {customerId: 1})
标签: sql mongodb mongodb-query aggregation-framework