Cheat Sheet6 min read
SQL SELECT & WHERE Cheat Sheet
A beginner-friendly reference for choosing columns, filtering rows, combining conditions, and handling NULL correctly.
SELECT: choose the columns
SELECT defines the shape of your result. Name the required columns explicitly in production queries instead of relying on SELECT *.
SELECT employee_id, employee_name, department, salary
FROM employees;WHERE: filter rows
WHERE keeps rows that satisfy a condition. Text values use quotes; numeric values do not.
- Use AND when every condition must be true
- Use OR when at least one condition may be true
- Use parentheses when combining AND and OR
SELECT employee_name, salary
FROM employees
WHERE department = 'Engineering'
AND salary >= 70000;Handle NULL explicitly
NULL represents an unknown or missing value. Compare it with IS NULL or IS NOT NULL, not with the equals operator.
SELECT employee_name
FROM employees
WHERE manager_id IS NULL;A reliable beginner workflow
Start with the table, select only the columns you need, add one filter at a time, run the query, and inspect whether edge cases such as NULL values behave as expected.
Turn the concept into practice
Write real queries, run them safely, and compare the result with a verified solution.
Open Practice Arena