MongoDB Common Query

Source: Internet
Author: User

MONGO SQL Description
Db.users.find () SELECT * from Users Querying all data from the user table
Db.users.find ({"username": "Joe", "Age": 27}) SELECT * from the users where "username" = "Joe" and age = 27 People looking for username = Joe and age = 27
Db.users.find ({}, {"username": 1, "email": 1}) Select username, email from users Find the 2 subkeys of Username,email
Db.users.find ({"Age": {"$GT": 18}}) SELECT * from the users where age >18 Find a member of age > 18
Db.users.find ({"Age": {"$gte": 18}}) SELECT * from the users where age >=18 People looking for age >= 18
Db.users.find ({"Age": {"$lt": 18}}) SELECT * from the users where age <18 Find people in age < 18
Db.users.find ({"Age": {"$lte": 18}}) SELECT * from the users where age <=18 People looking for age <= 18
Db.users.find ({"username": {"$ne": "Joe"}}) SELECT * from users where username <> "Joe" Find username! = Joe Members
Db.users.find ({"Ticket_no": {"$in": [725, 542, 390]}}) SELECT * from the users where Ticket_no in (725, 542, 390) Conforms to Tickt_no results in this range
Db.users.find ({"Ticket_no": {"$nin": [725, 542, 390]}}) SELECT * from the users where ticket_no not in (725, 542, 390) Conforms to the results of tickt_no not in this range
Db.users.find ({"Name":/joey^/}) SELECT * from the users where name like "joey%" Find the first 4 characters for Joey

MongoDB Common Query

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.