SQL Comparison Operators
Comparison operators help you compare values in the WHERE clause to filter data.
🔹 Common Comparison Operators
| Operator | Meaning | Example |
|---|---|---|
= | Equal to | WHERE salary = 50000 |
<> or != | Not equal to | WHERE department <> 'HR' |
> | Greater than | WHERE salary > 60000 |
< | Less than | WHERE age < 30 |
>= | Greater than or equal to | WHERE experience >= 5 |
<= | Less than or equal to | WHERE age <= 40 |
🔹 Usage Example
SELECT * FROM employees WHERE salary >= 50000 AND department <> 'Sales';🧠 Quick Recap
- Use
=and<>(or!=) for equality and inequality - Use
<,>,<=,>=for range checks - Essential for filtering rows in your queries
✅ Master these to control exactly which rows you get!
