Home  >  Article  >  Database  >  MongoDB插入查询数据(二), 条件查询

MongoDB插入查询数据(二), 条件查询

WBOY
WBOYOriginal
2016-06-07 17:56:31976browse

db.things.find({name:"mongo" }).forEach(printjson);{ "_id" : ObjectId("501c7e5cab2f3c46faf8e68a"), "name" : "mongo" } 相当于 SELECT * FROM things WHERE . 里指定元素的名字 SELECT name FROM things WHERE db.things.find({name:"mongo"}, {name:

> db.things.find({name:"mongo"}).forEach(printjson); { "_id" : ObjectId("501c7e5cab2f3c46faf8e68a"), "name" : "mongo" }

相当于SELECT * FROM things WHERE

…”.

 

里指定元素的名字

 

SELECT name FROM things WHERE

 

> db.things.find({name:"mongo"}, {name:true}).forEach(printjson); { "_id" : ObjectId("501c7e5cab2f3c46faf8e68a"), "name" : "mongo" }

 

方法.

> db.things.find().limit(2); { "_id" : ObjectId("501c7e5cab2f3c46faf8e68a"), "name" : "mongo" } { "_id" : ObjectId("501c7e65ab2f3c46faf8e68b"), "x" : 3 }

 

 

 

,香港虚拟主机,网站空间,服务器空间
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn