Beginner

50. Comparison Operators

Understand the main SQL comparison operators used to compare values and filter records.

📘 Lesson 50 of 728 ⏱ 8 min 🎯 Beginner

Comparison operators evaluate relationships between two values and return a logical result. Common SQL comparison operators include =, <>, !=, >, <, >=, and <=. They are widely used in WHERE, HAVING, JOIN conditions, and other SQL expressions.

Comparison operators form the foundation of SQL filtering. Almost every analytical query contains conditions that determine which records should be included in the result.

An analyst may need employees whose salary is greater than ₹50,000 and whose department is not IT. Comparison operators can be combined with logical operators to create this filter.

SQL
SELECT
    EmployeeName,
    Department,
    Salary
FROM Employees
WHERE Salary >= 50000
AND Department <> 'IT';

Comparison operators are used throughout data analysis, financial reporting, customer analysis, employee analytics, compliance monitoring, transaction analysis, and business intelligence.

  • = checks equality.
  • <> and != represent not equal in supported systems.
  • > checks greater than.
  • < checks less than.
  • >= checks greater than or equal to.
  • <= checks less than or equal to.
  • Comparison operators are commonly used with WHERE.
What are SQL comparison operators?

They are operators used to compare values, such as =, <>, >, <, >=, and <=.

Where are comparison operators commonly used?

They are commonly used in WHERE conditions, HAVING conditions, JOIN conditions, and SQL expressions.

Have you finished this lesson?

Introduction to SQL – All Lessons