mongo常用sql

时间:2019-07-09 12:22:15   收藏:0   阅读:101

区间查询:
db.getCollection(‘repay_batch_info‘).find({"batch_no":{"$gt":"mnwp2pt005","$lt":"mnwp2pt107"}})

and查询:
db.getCollection(‘loan_instruction‘).find({$and:[{"channel_code" : "xmjr"},{"status" : "SUCCESS"}]})

模糊查询:
db.getCollection(‘request_log‘).find({"url" : {$regex:/LP10001/}})

 

联表查寻:

db.apply.aggregate([
{
$lookup:
{
from: "request_log",
localField: "apply_id",
foreignField: "apply_id",
as: "request_log"
}
},
{ $match : {"request_log.url" : {$regex:/LP10001/}} }
])

对应T-sql:

select * from apply a left join request_log r on a.apply_id = r.apply_id where r.request_log.url like ‘%LP10001%‘

原文:https://www.cnblogs.com/carlvine/p/11156294.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!