</>
Skip to content
SQL lessons (40/54)

SQL — Operators

Comparison operators

-- Equal
SELECT * FROM users WHERE age = 25;

-- Not equal
SELECT * FROM users WHERE age != 25;
SELECT * FROM users WHERE age <> 25;

-- Greater than
SELECT * FROM users WHERE age > 25;

-- Less than
SELECT * FROM users WHERE age < 25;

-- Greater than or equal
SELECT * FROM users WHERE age >= 25;

-- Less than or equal
SELECT * FROM users WHERE age <= 25;

BETWEEN

SELECT * FROM users WHERE age BETWEEN 20 AND 30;

IN

SELECT * FROM users WHERE city IN ('NYC', 'LA', 'Chicago');

LIKE

-- Starts with
SELECT * FROM users WHERE name LIKE 'A%';

-- Ends with
SELECT * FROM users WHERE name LIKE '%son';

-- Contains
SELECT * FROM users WHERE name LIKE '%ali%';

-- Single character
SELECT * FROM users WHERE name LIKE '_lice';

IS NULL

SELECT * FROM users WHERE email IS NULL;
SELECT * FROM users WHERE email IS NOT NULL;

Mini Practice

  1. Use comparison operators
  2. Filter with BETWEEN
  3. Use IN operator
  4. Pattern match with LIKE

Up Next

Continue with And/Or - Logical operators.

Related Topics

Frequently Asked Questions about Operators

What is Operators in SQL?

Operators is a fundamental concept in SQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Operators?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Operators.

Why is Operators important in SQL?

Operators is essential for SQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.