SQL WHERE

Article Summary

The WHERE clause lets you filter rows based on conditions, so you get only the data you want. πŸ”Ή Basic Syntax This returns employees with salary greater than 50,000. πŸ”Ή Common Operators in WHERE πŸ”Ή Multiple Conditions 🧠 Quick Recap βœ… Master WHERE to get exactly the data you want!

The WHERE clause lets you filter rows based on conditions, so you get only the data you want.

πŸ”Ή Basic Syntax

SELECT * FROM employees WHERE salary > 50000;

This returns employees with salary greater than 50,000.

πŸ”Ή Common Operators in WHERE

-- Comparison
=, <>, >, <, >=, <=

-- Logical
AND, OR, NOT

-- Between two values
salary BETWEEN 40000 AND 60000

-- Match a list of values
department IN ('HR', 'Sales', 'IT')

-- Pattern matching (see next topic for LIKE)
name LIKE 'J%'

-- Check for NULL
manager_id IS NULL

πŸ”Ή Multiple Conditions

SELECT * FROM employees 
WHERE department = 'IT' AND salary > 60000;

🧠 Quick Recap

  • WHERE filters rows based on condition(s)
  • Use comparison and logical operators
  • Supports IN, BETWEEN, LIKE, IS NULL for powerful filtering

βœ… Master WHERE to get exactly the data you want!

Was this helpful?