Stage 2 · Lesson 2 of 8
Filtering rows with WHERE
WHERE keeps only the rows where a condition is true. Combine conditions with AND, OR and NOT. Use IN to match a list of values, for a range that includes both ends, and LIKE for simple text patterns, where % means any text and _ means exactly one character.
Filter in SQL rather than in your application. The database then sends back only the rows you need, and it can use indexes to find them fast, which matters a lot later. Whether text comparisons care about upper and lower case depends on the database and its (its rules for comparing text). MySQL and usually ignore case by default, while is .
Common trapmixing AND and OR without brackets: AND binds tighter, so a OR b AND c means a OR (b AND c), which silently returns extra rows.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking SQL for Tech Interviews
Design Gurus · Intermediate · Subscription
The basics, order of execution and functions chapters, each followed by graded problems
- CourseFreeSQLBolt
SQLBolt · Beginner
Free: Lessons 1 to 4, 8, 9 and 12 cover SELECT, filtering, sorting, NULLs, expressions and query order
Practise
Keep handy
Also worth your time
Walks through the logical order a query is evaluated in, which explains most early errors