SQL Tutorial · SQL Basics · Lesson 4 of 36

SQL WHERE

Filter rows with WHERE and comparison operators.

Filtering rows

WHERE keeps only the rows where the condition is true:

Example 1Try it yourself
SELECT name, price FROM products WHERE price > 50;

Output

name | price
Mechanical Keyboard | 89
4K Monitor | 329
Standing Desk Mat | 59.9
Robot Kit | 120

Comparison operators

Operator Meaning
= equal
<> or != not equal
> < >= <= greater / less than
BETWEEN, IN, LIKE, IS NULL covered in the next lessons

Text values go in single quotes. Text comparison may be case-sensitive depending on the database.

Example 2Try it yourself
SELECT name, country FROM customers WHERE country = 'UK';
SELECT order_id, order_date FROM orders WHERE status <> 'delivered';
SELECT order_id, order_date FROM orders WHERE order_date >= '2026-05-01';

Output

name | country
Ada Lovelace | UK
Alan Turing | UK

order_id | order_date
4 | 2026-02-14
6 | 2026-03-03
8 | 2026-04-01
9 | 2026-04-22
11 | 2026-05-30

order_id | order_date
10 | 2026-05-09
11 | 2026-05-30
12 | 2026-06-15

Test yourself

Which quotes should you use for text values in SQL?

  1. Single quotes
  2. Double quotes
  3. Backticks
  4. No quotes
Show answer

Answer: Single quotes

Standard SQL uses single quotes for strings; double quotes are for identifiers (column/table names).