# Comparison Operators

*noun*

say it: **“kum-PAIR-ih-sun OP-uh-ray-terz”** **/kəmˈpɛrɪsən ˈɑpəreɪtərz/**

Symbols or words that compare two values, such as greater than or not equal to; in a MongoDB filter they start with a dollar sign, such as $lt.

## What are **comparison operators** in a MongoDB filter?

**Comparison operators** compare a field with a value inside a filter: `$gt` (greater than), `$gte`, `$lt` (less than), `$lte`, `$ne` (not equal), and `$in` and `$nin` for a list. Each goes in its own small document after the field's name.

```javascript
db.recipes.find({ minutes: { $lt: 30 } });            // quicker than 30 minutes
db.recipes.find({ servings: { $gte: 4, $lte: 6 } });  // 4 to 6 servings
```

## In a sentence

- “With the **comparison operators** $gte and $lte, the filter found recipes that serve 4 to 6 people.”
- “MongoDB's **comparison operators** go inside braces after the field: { minutes: { $lt: 30 } }.”

Level: Apprentice · [More MongoDB terms at this level](https://www.ask-codey.com/glossary?category=mongodb&level=2)

Updated: November 19, 2026

## In other subjects

- [Comparison Operators in C#](https://www.ask-codey.com/glossary/comparison-operators-c-sharp)
- [Comparison Operators in Java](https://www.ask-codey.com/glossary/comparison-operators-java)
- [Comparison Operators in JavaScript](https://www.ask-codey.com/glossary/comparison-operators-javascript)
- [Comparison Operators in PowerShell](https://www.ask-codey.com/glossary/comparison-operators-powershell)
- [Comparison Operators in Python](https://www.ask-codey.com/glossary/comparison-operators)

Source: https://www.ask-codey.com/glossary/comparison-operators-mongodb
