当前位置:网站首页>MongoDB 常用查询语句
MongoDB 常用查询语句
2022-08-10 02:44:00 【Falling the bowie】
- 数据库工具:Navicat
- id :1-7 createTime是字符串类型,8-13 createTime是date类型
直接贴代码:
//查所有
db.getCollection("memberReadHistory").find()
//条件范围查询
db.getCollection('memberReadHistory').find({"memberId":3})
db.getCollection('memberReadHistory').find({"memberId":3,"productId":500})
db.getCollection('memberReadHistory').find({"memberId":{$gt:2}})
db.getCollection('memberReadHistory').find({"memberId":{$gt:2},"productId":500})
//使用 $and 多条件查询
db.getCollection('memberReadHistory').find({$and:[{"memberId":3},{"createTime":{$gte:"2022-08-07 14:38:00",$lte:"2022-08-07 14:40:00"}}]})
//时间字符串范围查询
db.getCollection('memberReadHistory').find({"memberId":3,"createTime":{$gte:'2022-08-07 14:38:00',$lte:'2022-08-07 14:40:00'}})
//date时间查询,ISODate("2022-08-07T07:22:44.375Z")
db.getCollection('memberReadHistory').find({$and:[{"memberId":3},{"createTime":{$gte:ISODate("2022-08-07T07:22:44.375Z")}}]})
边栏推荐
猜你喜欢
【Image Classification】2022-ConvMixer ICLR
实例044:矩阵相加
[Kali Security Penetration Testing Practice Course] Chapter 8 Web Penetration
实例042:变量作用域
【语义分割】2022-HRViT CVPR
论文理解:“PIAT: Physics Informed Adversarial Training for Solving Partial Differential Equations“
实例048:数字比大小
MySQL: What MySQL optimizations have you done?
高精度加法
实例046:打破循环
随机推荐
T5: Text-to-Text Transfer Transformer
The Evolutionary History of the "Double Gun" Trojan Horse Virus
ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library
2022.8.8考试游记总结
6 common plugin recommendations in Pycharm
MySQL: What MySQL optimizations have you done?
【Image Classification】2022-CycleMLP ICLR
Leetcode 47 全排列Ⅱ
QT modal dialog and non-modal dialog learning
what is a microcontroller or mcu
2022.8.8 Exam area link (district) questions
Example 045: Summation
2022.8.8 Exam questions for photographer Lao Ma (photographer)
如何让导电滑环信号更好
2022.8.9 Remainder of Exam Balance--1000 Question Solutions
Research on IC enterprises
[Kali Security Penetration Testing Practice Course] Chapter 9 Wireless Network Penetration
2022.8.8 Exam written in memory (memory)
[Kali Security Penetration Testing Practice Tutorial] Chapter 6 Password Attack
The 25th day of the special assault version of the sword offer