SQL Comparison Operators

Article Summary

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 […]

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!

Was this helpful?