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 |