如何在mongodb中编写下面的sql等价查询
select a.id from test a
where not exists(select 1 from test b where b.id=a.id and b.name<>a.name)
请咨询
答案 0 :(得分:0)
您可以使用$ lookup语法,例如:
db.collection_A.aggregate([
{
"$lookup": {
"from": "collection_B",
"localField": "_id",
"foreignField": "_id",
"as": "references"
}
}, {
"$match": {
"references": []
}
}
])