码迷,mamicode.com
首页 > 数据库 > 详细

简单oracle 查询语句 转换为 mongo 查询语句

时间:2020-02-10 17:57:51      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:简单   sum   ruid   码云   font   find   pre   rom   查询   

可以将简单的单表查询语句转换成Mongo过滤条件

列:

1、

SELECT score,person as name FROM demo WHERE  person like %z and score between 80 and 100
db.demo.aggregate([ 
        {"$match": {"$and": [{"person": {"$regex": "^.*z$", "$options": "i"}}, {"score": {"$gte": 80, "$lte": 100}}]}} ,
        {"$project": {"score": "$score", "name": "$person", "_id": 0}}
    ])

 

2、

SELECT * FROM demo WHERE score < 90 and person is not null or (score >= 90 and person <> zsa) or person in (tyh,jhh)
db.demo.find( 
        {"$or": [{"$and": [{"score": {"$lt": 90}}, {"person": {"$exists": true}}]}, {"$and": [{"score": {"$gte": 90}}, {"person": {"$ne": "zsa"}}]}, {"person": {"$in": ["tyh", "jhh"]}}]}
    )

 

不支持函数(sum() ,count() ....) 、常数等式(1=1 或者 1!=2 ....)

依赖 druid 的 sql 解析

代码位置:码云

简单oracle 查询语句 转换为 mongo 查询语句

标签:简单   sum   ruid   码云   font   find   pre   rom   查询   

原文地址:https://www.cnblogs.com/zengsa/p/12291724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!