Home  >  Article  >  Database  >  mongodb中的AND和OR

mongodb中的AND和OR

WBOY
WBOYOriginal
2016-06-07 14:58:472374browse

mongodb中的AND和OR 例如在集合XXX中寻找名字为BuleRiver或者BuleRiver2的信息: [javascript] db.XXX.find({$or:[{name:BuleRiver}, {name:BuleRiver2}]}); 如果是AND关系的话,直接这样 [javascript] db.XXX.find({name:BuleRiver, level:1});


mongodb中的AND和OR

 

例如在集合XXX中寻找名字为BuleRiver或者BuleRiver2的信息:

 

[javascript] 

 

db.XXX.find({"$or":[{"name":"BuleRiver"}, {"name":"BuleRiver2"}]});  

 

如果是AND关系的话,直接这样

 

[javascript] 

 

db.XXX.find({"name":"BuleRiver", "level":1});  

 

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