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 查询语句
最新推荐文章于 2024-07-25 19:47:36 发布