MongoDB等效于SQL"OR" [英] MongoDB equivalent of SQL "OR"
本文介绍了MongoDB等效于SQL"OR"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,MongoDB在查找记录时默认为"AND".例如:
So, MongoDB defaults to "AND" when finding records. For example:
db.users.find({age: {'$gte': 30}, {'$lte': 40}});
上面的查询发现> = 30 AND < = 40岁的用户.
The above query finds users >= 30 AND <= 40 years old.
我将如何找到< = 30 OR > = 40岁的用户?
How would I find users <= 30 OR >= 40 years old?
推荐答案
在不久的将来将会有一个or运算符.每晚的Mongodb构建已具有$ or.您还可以使用$ where并使用JavaScript表示or.
There will be an or operator in the near future. The nightly Mongodb build has already an $or. You can also use $where and use JavaScript to express the or.
请参见 http://groups.google.com/group/mongodb-user/browse_thread/thread/a9a4d8b863d84601
这篇关于MongoDB等效于SQL"OR"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文