查询集合c中y的值为null或者不存在

>db.c.find( { “y” : null } )

 

查询集合c中y的值为null,(仅返回y的值为null的数据,不会返回不存在的)

>db.c.find( { “y” : { $type : 10 } } )

还有一种写法如下

>db.c.find({“y”:{“$in”:[null], “$exists”:true}})

 

查询集合c中y的值不存在(不会返回y的值为null的数据)

>db.c.find( { “y” : { $exists : false } } )

 

查询集合c中y的值不为null且存在的记录

 

>db.c.find( { “y” : {"$ne":null, $exists: true }} )

或者:>db.c.find( { “y” : {"$ne":null }} )

相关文章:

  • 2022-12-23
  • 2021-10-02
  • 2021-07-27
  • 2022-01-08
  • 2022-12-23
  • 2021-12-21
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-06
  • 2021-07-22
  • 2021-09-17
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案