- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find MongoDB records with Price less than a specific value
To check the records with Price less than a specific value, use $lt. Let us create a collection with documents −
> db.demo728.insertOne({Price:75}); { "acknowledged" : true, "insertedId" : ObjectId("5eab413c43417811278f589b") } > db.demo728.insertOne({Price:59}); { "acknowledged" : true, "insertedId" : ObjectId("5eab414043417811278f589c") } > db.demo728.insertOne({Price:79}); { "acknowledged" : true, "insertedId" : ObjectId("5eab414543417811278f589d") } > db.demo728.insertOne({Price:89}); { "acknowledged" : true, "insertedId" : ObjectId("5eab414843417811278f589e") }
Display all documents from a collection with the help of find() method −
> db.demo728.find();
This will produce the following output −
{ "_id" : ObjectId("5eab413c43417811278f589b"), "Price" : 75 } { "_id" : ObjectId("5eab414043417811278f589c"), "Price" : 59 } { "_id" : ObjectId("5eab414543417811278f589d"), "Price" : 79 } { "_id" : ObjectId("5eab414843417811278f589e"), "Price" : 89 }
Following is the query to find records based on a condition −
> db.demo728.find({Price:{$lt:80}});
This will produce the following output −
{ "_id" : ObjectId("5eab413c43417811278f589b"), "Price" : 75 } { "_id" : ObjectId("5eab414043417811278f589c"), "Price" : 59 } { "_id" : ObjectId("5eab414543417811278f589d"), "Price" : 79 }
- Related Articles
- MongoDB query to group records and display a specific value with dot notation
- Query MongoDB for a datetime value less than NOW?
- MongoDB query to match documents with array values greater than a specific value
- Find records on or after a specific date in MongoDB?
- Find out the records of students with more than a specific score in MySQL?
- Match MongoDB documents with field value greater than a specific number and fetch them?
- Find document with array that contains a specific value in MongoDB
- Find value above a specific value in MongoDB documents?
- Find the document by field name with a specific value in MongoDB?
- Find MongoDB document with array containing the maximum occurrence of a specific value
- Find records with a specific last digit in column with MySQL
- How to select records that begin with a specific value in MySQL?
- Searching a specific domain name from URL records in MongoDB?
- Display only the employee names with specific salaries in MongoDB documents with employee records?
- Excel COUNTIF Function – Count cells that are not blank, greater/less than, or contain a specific value

Advertisements