zoukankan      html  css  js  c++  java
  • MongoDB(课时7 逻辑运算)

    3.4.2.2 逻辑运算

    逻辑运算主要三种类型:与($and),或($or),非($not、$nor)。

    范例:查询年龄在20~21岁的学生信息

    db.students.find({"age" : {"$gte" : 20, "$lte" : 21}}).pretty()

    在逻辑运算的时候"and"的连接是最容易的,因为只需要利用","分隔条件即可。

    范例:查询年龄大于19岁,或者成绩大于90分的学生信息

    db.students.find({"$or" : [{"age" : {"$gt" : 19}}, {"score" : {"$gt" : 90}}]}).pretty()

    或的连接需要为数据设置数组的过滤,即添加中括号。

    范例: 进行或的求反操作

    db.students.find({"$nor" : [{"age" : {"$gt" : 19}}, {"score" : {"$gt" : 90}}]}).pretty()

  • 相关阅读:
    新的知识点
    知识点
    9.14知识点
    列表内容
    css的背景和边框
    css的text和font
    css
    js 第一天
    浏览器的差距
    布局
  • 原文地址:https://www.cnblogs.com/keye/p/7954268.html
Copyright © 2011-2022 走看看