Lesson 8 / 28

SELECT & WHERE

Read rows back, and filter them with WHERE.

SELECT basics

SELECT reads columns from a table; * means every column.

SELECT name, email FROM customers;

Output:

name        | email
Asha Rao    | asha@example.com
Rahul Mehta | rahul@example.com
Priya Nair  | priya@example.com

Filtering with WHERE

WHERE keeps only rows matching a condition. Comparison operators: =, != (or <>), <, >, <=, >=.

SELECT name FROM customers
WHERE email LIKE '%example.com';

Output:

name
Asha Rao
Rahul Mehta
Priya Nair

AND / OR / IN / BETWEEN

Combine conditions with AND/OR, check a set with IN (1,2,3), and a range with BETWEEN 10 AND 20.