欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

<转>MongoDB 查询语句 博客分类: NoSQL mongodb语句 

程序员文章站 2024-03-01 15:52:46
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---查询语句---
 Select a, b from users
 db.users.find({},{a:1, b:1})
 查询表
 Select * from users
 db.users.find()
 查询表
 Select * from users where age=33
 db.users.find({age:33})
 条件查询
 Select a, b from users where age=33
 db.users.find({age:33},{a:1, b:1})
 条件查询
 select * from users where age<33
 db.users.find({'age':{$lt:33}})
 条件查询
 select * from users where age>33 and age<=40
 db.users.find({'age':{$gt:33,$lte:40}})
 条件查询
 select * from users where a=1 and b='q'
 db.users.find({a:1,b:'q'})
 条件查询
 select * from users where a=1 or b=2
 db.users.find( { $or : [ { a : 1 } , { b : 2 } ] } )
 条件查询
 select * from users limit 1
 db.users.findOne()
 条件查询
 select * from users where name like "%Joe%"
 db.users.find({name:/Joe/})
 模糊查询
 select * from users where name like "Joe%"
 db.users.find({name:/^Joe/})
相关标签: mongodb 语句