我有两个收款记录像这样
// collection_1
{
"_id" : ObjectId("64100b43317d38bfe6238deb"),
"email" : "email@google.com",
"is_active" : true,
"stage_id" : 2
}
另一个收藏记录是这样的
// collection_2
{
"_id" : ObjectId("24003f7f345c72739747b6f9"),
"collection_1_id":ObjectId("64100b43317d38bfe6238deb"),
"stage_id" : 2,
"link":"www.google.com"
}
因此,我希望从collection_1中查找查询,如下所示
select * from collection_1
join collection_2
where collection_1._id=collection_2.collection_1_id
and
collection_1.stage_id=collection_2.stage_id
我已经搜索了,但我找不到匹配多个字段的方法
1条答案
按热度按时间vcudknz31#
您应该在
$lookup
中进行管道传输,如下所示:Playground link.