search

Home  >  Q&A  >  body text

mongodb的java开发中使用两个字段相等查询条件应该怎么写?

也就是类似sql中的where 字段A=字段B这样的条件,我查了下网上有些帖子中写的用$where的方式我查询的时候会出错,类似于:new Document("$where",new Document("字段A", "字段B")),请教应该怎么写才对?

黄舟黄舟2792 days ago616

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-28 09:08:01

    Mongo does not support queries that compare two fields with each other. You can only read and compare the two fields through the program. This effect cannot be achieved in the query conditions.

    reply
    0
  • Cancelreply