douren6035 2019-03-05 14:59
浏览 294

在MongoDB中使用WHERE和JOIN

I have 2 collections, I want to select the records from a collection according to another collection,

let me explain my mean by example:

Collection1:

id, user_id, completed
1 , 1     , true
2 , 1     , false
3 , 2     , true
4 , 3     , true
5 , 4     , false

Collection2:

id, username
1 , test
2 , test 2
3 , test 3
4 , test 4

I want to select users from collection2 which the completed column in collection1 are false (the result should be (1,test),(2,test 4) )

because I'm a newbie in MongoDB I don't know what should I do, I can do it in MySQL and PostgreSQL with join but here what should I do?

I read the aggregation-pipeline in MongoDB documentation but I cannot figure out.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条