ADVERTISEMENT

SQL Comparison Operators

Comparison operators help you compare values in the WHERE clause to filter data.

🔹 Common Comparison Operators

OperatorMeaningExample
=Equal toWHERE salary = 50000
<> or !=Not equal toWHERE department <> 'HR'
>Greater thanWHERE salary > 60000
<Less thanWHERE age < 30
>=Greater than or equal toWHERE experience >= 5
<=Less than or equal toWHERE 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!

ADVERTISEMENT