MongoDB结合$和$或

时间:2016-12-31 19:53:19

标签: mongodb

select * 
from job 
where 
    (title LIKE %xxx% OR dsc LIKE %xxx% OR requirements LIKE %xxx% ) 
    AND 
    (country LIKE %xxx%)

我如何在MongoDB中执行此操作?

1 个答案:

答案 0 :(得分:1)

使用它:

db.job.find({
    $and : [
        {$or : [
            {title  : \xxx\},
            {dsc : \xxx\},
            {requirements : \xxx\}
        ]},
        {country : \xxx\}
    ]
})