How to query MongoDB with “like”?

后端 未结 30 2067
予麋鹿
予麋鹿 2020-11-21 05:51

I want to query something with SQL\'s like query:

SELECT * FROM users  WHERE name LIKE \'%m%\'

How to do I achieve the same in

30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 06:24

    I found a free tool to translate MYSQL queries to MongoDB. http://www.querymongo.com/ I checked with several queries. as i see almost all them are correct. According to that, The answer is

    db.users.find({
        "name": "%m%"
    });
    

提交回复
热议问题