当前位置:网站首页>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")}}]})
边栏推荐
猜你喜欢
随机推荐
Difference Between Data Mining and Data Warehousing
P1564 Worship
Robust Real-time LiDAR-inertial Initialization(实时鲁棒的LiDAR惯性初始化)论文学习
MySQL: What MySQL optimizations have you done?
论旅行之收获
第三章 搜索与图论(二)
跨站请求伪造(CSRF)攻击是什么?如何防御?
【语义分割】2022-HRViT CVPR
liunx PS1 设置
2022.8.8考试游记总结
当我操作dms客户端的时候,我要操控好几个阿里云账号下的数据库,但是这边每次切换都会把我的登录记录删
量化交易策略介绍及应用市值中性化选股
电子产品结构设计中的电磁兼容性(EMC)设计
2022.8.8考试摄像师老马(photographer)题解
2022.8.9考试独特的投标拍卖--800题解
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
flutter异步
[Red Team] ATT&CK - Self-starting - Self-starting mechanism using LSA authentication package
The 25th day of the special assault version of the sword offer
【CC3200AI 实验教程5】疯壳·AI语音人脸识别(会议记录仪/人脸打卡机)-定时器