WHERE Clause — Filters rows before any aggregation. Every condition is evaluated per individual row.
Comparison Operators — Use =, <, >, <=, >=, <> for comparing column values.
BETWEEN a AND b — Range check — inclusive of both endpoints. Equivalent to col >= a AND col <= b.
IN (x, y, ...) — Set membership. Equivalent to col=x OR col=y. Cleaner for multiple values.
LIKE Pattern — % matches any sequence of characters. _ matches exactly one character.
IS NULL — The only correct way to check for missing values. = NULL never evaluates to TRUE in SQL.
Compound (AND/OR/NOT) — Combine multiple conditions. Use parentheses to control precedence.
ORDER BY — Sorts the final result. Default direction is ASC. Add DESC to reverse.
Multiple ORDER BY — ORDER BY type ASC, rent DESC — first sorts by type, then by rent within each type.
COUNT(*) — Counts all rows including NULLs. COUNT(col) skips NULL values in that column.
COUNT DISTINCT — COUNT(DISTINCT col) removes duplicates before counting.
SUM / AVG — Operate on numeric columns only. NULL values are automatically ignored.
MIN / MAX — Work on numbers, strings (alphabetical order), and dates alike.
FORMAT(n,d) — MySQL function: formats a number with d decimal places and thousands separator.
Aggregate Rule — Aggregate functions return one value per group (or one value for the whole table if no GROUP BY).