mongo 多条件复杂查询 in java

vbubble 2012-11-15 11:08:54

查询需求是包含范围查询、指定字段查询、模糊查询。。。
就像普通的sql:
select * from person where age between 30 and 50 and work = 'IT' and tech like "%技术%"

坑爹的,看了些文档,没找到符合此需求的查询方法,求介绍

...全文
827 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
iihero_ 2012-11-19
  • 打赏
  • 举报
回复
引用 2 楼 rucypli 的回复:
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 use……
赞。。。。
zoujian911 2012-11-19
  • 打赏
  • 举报
回复
正则表达式,绝对没问题……
rucypli 2012-11-16
  • 打赏
  • 举报
回复
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/})
vbubble 2012-11-16
  • 打赏
  • 举报
回复
求介绍

1,747

社区成员

发帖
与我相关
我的任务
社区描述
MongoDB相关内容讨论区
社区管理员
  • MongoDB社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧