Gomaa Intelligence.Data Hub
عربي

Foundations › SQL › SQL Basics

🔎 SQL Basics

WHERE: Filtering Rows

Lesson 6 / 14· 9 min

WHERE makes the database return only rows that meet a condition.

OperatorMeaningExample
= <> < > <= >=Comparisonprice > 500
AND / OR / NOTCombine conditionscity = 'Cairo' AND ...
IN (...)Within a listcity IN ('Cairo','Giza')
BETWEEN a AND bBetween two values (inclusive)price BETWEEN 100 AND 300
LIKEPattern match (% any length, _ one char)name LIKE 'A%'
▶ Try it yourself

Electronics priced above 500. Open in SQL Lab

▶ Try it yourself

IN is cleaner than repeating OR. Open in SQL Lab

▶ Try it yourself

Orders from Q1 2026. Open in SQL Lab

▶ Try it yourself

Names starting with A. Open in SQL Lab

▶ Try it yourself

Parentheses fix the meaning. Open in SQL Lab

For advanced readers Dates and comparison

In SQLite dates are stored as ISO text (YYYY-MM-DD) so comparisons work. PostgreSQL, MySQL and SQL Server have a real DATE type. For time ranges prefer >= start and < the day after the end instead of BETWEEN when times are involved.

Exercise 1 — Show the name and price of Home products priced under 300.

Exercise 2 — Show the name and city of customers in Cairo or Alexandria whose name starts with M.

Exercise 3 — Show id and order_date of cancelled orders in 2026.

Summary
  • WHERE filters rows before any grouping.
  • IN, BETWEEN and LIKE shorten conditions.
  • Use parentheses when mixing AND and OR.

Want an expert to do it for you?

Gomaa Intelligence turns your data into clear reports and decisions. Tell us your problem and we will reply.

Get your data analyzed by an expert ↗