Filtering with WHERE
WHERE runs before anything else, so it decides how much work the rest has to do.
Open this lesson in the learning hubKey points
- WHERE keeps only the rows whose condition is true - it never changes the columns.
- Combine with
ANDandOR;ANDbinds tighter, so parenthesise when mixing. LIKEwith%matches any run of characters;_matches exactly one.IN (...)is shorthand for a chain of ORs on the same column.- NULL is not a value - use
IS NULL, never= NULL, which is never true.
WHERE decides which rows survive, and doing it early is what keeps a query fast.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the MySQL Course course, and every lesson in it is listed on the MySQL Course contents page.