DevPath · Learn to code ESPTEN

Introduction to SQL

Filter rows with WHERE

The WHERE clause

WHERE filters: it only returns the rows that meet a condition.

SELECT name, price FROM products WHERE price > 100;

Common comparison operators:

Operator Meaning
= equal
<> not equal
> < >= <= greater / less (than or equal)

For text, comparisons go between single quotes:

SELECT * FROM products WHERE category = 'peripherals';

You can combine conditions with AND and OR:

SELECT * FROM products WHERE price > 20 AND category = 'peripherals';
Put this into practice

DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.

Start free in the app →
← Relational databases and SQLSort with ORDER BY →