SQL Filtering

Filtering in SQL means narrowing down a result set to only the rows that meet specific conditions, using the WHERE clause - one of the most commonly used parts of a SELECT query.

Basic Syntax

SELECT * FROM customers
WHERE city = 'Noida';

Comparison Operators

  • = - equal to
  • != or <> - not equal to
  • >, < - greater than, less than
  • >=, <= - greater than or equal to, less than or equal to

Filtering Examples

-- Customers who joined after a certain date
SELECT * FROM customers WHERE signup_date > '2025-01-01';

-- Orders above a certain amount
SELECT * FROM orders WHERE amount >= 5000;
Filtering happens before sorting and grouping in a query's logical order - the database evaluates WHERE first to reduce the number of rows it has to work with.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course