Keeping only the rows you mean
WHERE filters rows before anything else happens. Only rows where the condition is true survive.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Almost no question is about every row: this customer, last month, unpaid, active.
How to think about it
Write the SELECT, then ask 'which rows?' and put that as a condition on a column. Text needs single quotes; numbers do not.
Worked example
SELECT title FROM filmsWhat to show.
WHERE year > 2000 AND rating = 'PG';Both conditions must hold. 'PG' is text, so quoted.
Your turn
Only films from 1999.
SELECT title FROM films WHERE year 1999;
Run a query against real tables
The trap
WHERE col = NULL never matches anything. NULL is not equal to anything, even NULL. Use IS NULL.
Practise WHERE on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.