ADVERTISEMENT

SQL WHERE

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!

ADVERTISEMENT