Year End Sale: Get Upto 40% OFF on Live Training! Offer Ending in
D
H
M
S
Get Now
Mongo DB Comparison Operators

Mongo DB Comparison Operators

25 Jul 2024
Intermediate
12.4K Views
1 min read
Learn with an interactive course and practical hands-on labs

Free MongoDB Course: Mongodb Free Course for Beginners

In RDBMS, you can use comparison operators like as >, <, <=, and >= while writing a SQL query. Mongo shell also has the same comparison operators but they are used with a different notation. Here is a comparison list of Mongo shell operators and SQL operators.
Mongo Shell Operators
SQL Operators
gt
>
lt
<
gte
>=
lte
<=

AND and OR Operators

Like RDBMS, MongoDB also supports OR and AND operators. You can use $or for an OR operator and $and for an AND operator.

db.users.find( { $or : [{lastname :"chauhan",lastname:"kumar"}] })
db.users.find( { $and : [{firstname :"deepak",lastname:"kumar"}] })
What do you think?
That’s it for now! I hope you get a good idea how to use Mongo shell comparison operators to query your mongo database. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.
Share Article
About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at ScholarHat)

Shailendra Chauhan, Founder and CEO of ScholarHat by DotNetTricks, is a renowned expert in System Design, Software Architecture, Azure Cloud, .NET, Angular, React, Node.js, Microservices, DevOps, and Cross-Platform Mobile App Development. His skill set extends into emerging fields like Data Science, Python, Azure AI/ML, and Generative AI, making him a well-rounded expert who bridges traditional development frameworks with cutting-edge advancements. Recognized as a Microsoft Most Valuable Professional (MVP) for an impressive 9 consecutive years (2016–2024), he has consistently demonstrated excellence in delivering impactful solutions and inspiring learners.

Shailendra’s unique, hands-on training programs and bestselling books have empowered thousands of professionals to excel in their careers and crack tough interviews. A visionary leader, he continues to revolutionize technology education with his innovative approach.
Accept cookies & close this