Basics · Lesson 3 of 19

Filtering with WHERE

WHERE filters your results to only matching rows.

SELECT * FROM employees
WHERE department_id = 1;

This returns only employees in department 1.

Comparison operators:

  • = equals
  • > greater than
  • < less than
  • >= greater than or equal
  • <= less than or equal
  • != or <> not equal

Text values need quotes:

WHERE first_name = 'John'
Check your understanding

Find employees earning more than $90,000.

Examples run on the employees sample database. Open any of them in the playground to experiment.