|
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 查询语句
最新推荐文章于 2025-12-01 22:00:30 发布
本文对比了SQL与MongoDB中的查询语法,包括基本查询、条件查询、模糊查询等操作,帮助读者理解两种数据库系统的查询差异。
1万+

被折叠的 条评论
为什么被折叠?



