Home >Database >Mysql Tutorial >MongoDB插入查询数据(二), 条件查询
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 }
,香港虚拟主机,网站空间,服务器空间