WHERE
WHERE filters rows before grouping. SELECT name FROM students WHERE marks < 40; only fail rows. Conditions use =, <, >, <>, LIKE, IN, BETWEEN, IS NULL, AND, OR.
AND: both must be true. OR: either. Use brackets: WHERE (city = 'Pune' OR city = 'Goa') AND marks < 40. Without brackets, AND binds tighter than OR — easy viva trap.
WHERE marks = NULL is never true. Use IS NULL. Strings in quotes: WHERE name = 'Asha'. Numbers without quotes.
Trap: filtering in PHP after SELECT *. Trap: WHERE on an expression that kills the index (WHERE YEAR(dob) = 2004) — prefer dob range.
On the example next to this theory — WHERE combines predicates with AND/OR; LIKE does pattern match.
FROM students
│
▼
WHERE city = 'Pune'
│
▼
SELECT name, marksWHERE marks < 40. AND/OR with brackets. IS NULL.