WHERE · SQL

Ch 1 · Reading Data — card 2 of 2.

WHERE filters rows by a condition. Text goes in single quotes; numbers compare directly. Combine with AND / OR. Look at the example: it keeps only the rows where dept_id equals 1 (the Engineering department), and shows just the first_name, last_name and salary columns. WHERE is how you ask a precise question of a big table, so most real queries use one. Try changing the number to see other departments.

SELECT first_name, last_name, salary FROM employees WHERE dept_id = 1;

Which clause filters which rows are returned?