当前位置:网站首页>Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
2022-07-23 22:37:00 【Growth path of Xiaobo test】
Come and learn today mongodb Usage of some other query statements in , It mainly contains the following contents :
1、 Logical operators $not
such as : Inquire about user surface age Not for 18 The data of :
db.user.find({age:{$ne:18}})
db.user.find({age:{$not:{$eq:18}}})Be careful : If the field to be queried does not exist , It will also count as a condition
2、 Logical operators $and
Such as query user surface name by “ Xiaobo ”, also age by 17 The data of
db.user.find({name:" Xiaobo ",age:17})
db.user.find({$and:[{name:" Xiaobo "},{age:17}]}) Be careful : $and The following must correspond to an array format , Otherwise, an error will be reported :

3、 Logical operators $or
Such as query user In the table name by “ Xiaobo ” perhaps “ Test Xiaobo ” The data of :
db.user.find({name:{$in:[' Xiaobo ',' Test Xiaobo ']}})
db.user.find({$or:[{name:{$eq:' Xiaobo '}},{name:{$eq:' Test Xiaobo '}}]})
db.user.find({$or:[{name:' Xiaobo '},{name:' Test Xiaobo '}]})4、 Logical operators $nor
For the front $and、$or、$not Usage of , You may have seen it , But for the $nor operation , You may see less ,$nor The simple understanding is : One of the conditions is not satisfied .
Such as query name Not for “ Xiaobo ” perhaps “ Test Xiaobo ” The data of :
db.user.find({name:{$nin:[' Xiaobo ',' Test Xiaobo ']}})
db.user.find({$nor:[{name:' Xiaobo '},{name:' Test Xiaobo '}]})Be careful : If the field to be queried does not exist , It will also count as a condition

If it helps you , Remember forward 、 Leaving a message. 、 give the thumbs-up 、 Pay more attention to Oh !
If you are confused about your current job , I don't know how to improve myself , You can see : Career masters will help you with your interview and job search + Occupation development
END

All original articles
The official account is issued at the first time. 「 Xiaobo's road to growth 」

Long press QR code / Wechat code scanning Add the author
边栏推荐
- Leetcode high frequency question 62. different paths: how many paths does the robot have from the upper left corner to the lower right corner? Pure probability permutation and combination problem, not
- D1-h development board - Introduction to Nezha development
- 记忆化搜索 - DP
- Inspiration from Buffett's shareholders' meeting 2021-05-06
- Altium designer—Arduino UNO原理图&PCB图(自制Arduino板)
- D1-H 开发板——哪吒 开发入门
- 怎么开户买收益百分之六的理财产品呢?
- [unity3d daily bug] unity3d solves "the type or namespace name" XXX "cannot be found (are you missing the using directive or assembly reference?)" Etc
- ES6箭頭函數的使用
- LeetCode高频题53. 最大子数组和,具有最大和的连续子数组,返回其最大和
猜你喜欢

zk 是如何解决脑裂问题的

Leetcode high frequency question 62. different paths: how many paths does the robot have from the upper left corner to the lower right corner? Pure probability permutation and combination problem, not

王学岗视频编码————MediaCodec编解码

Microsoft SQL Server数据库语言及功能使用(十三)

Excel password related

Introduction and project development of MVVM and mvvmlight (I)

D1-h development board - Introduction to Nezha development

Programmation JDBC pour MySQL

MySQL的JDBC编程

Matlab wavelet toolbox import signal error (doesn't contain one dimensional single)
随机推荐
The ultimate experiment of OSPF -- learn the example of OSPF century template
JMeter performance comprehensive practice - sign in and batch sign in
Ways to improve the utilization of openeuler resources 01: Introduction
ONEFLOW V0.8.0 officially released
torchvision.datasets.ImageFolder前的数据整理及使用方法
详解NAT技术
Explain NAT technology in detail
Leetcode high frequency question 53. maximum subarray sum, continuous subarray with maximum sum, return its maximum sum
Linked list - 203. remove linked list elements
What are the product life cycle, common project functions, and information flow
Rails with OSS best practices
Array - 59. Spiral matrix II
MySQL的 DDL和DML和DQL的基本语法
疯狂的牛市,下半场何去何从?2021-04-30
FL Studio 20.9 update Chinese version host Daw digital audio workstation
Programming in the novel [serial 20] the moon bends in the yuan universe
ospf终极实验——学会ospf世纪模板例题
记忆化搜索 - DP
The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)
思源笔记的字体比其他的编辑器(Atom,VSC,sublime)内字体渲染更细更淡