Learn to find exactly the data you need with WHERE clauses, comparison operators, pattern matching, and NULL handling. Then organize your results with ORDER BY and paginate with LIMIT and OFFSET.
The WHERE clause filters rows based on a condition. Only rows that satisfy the condition appear in the results. Start with the simplest filter: exact equality.
sqlite3 ecommerce.db.headers on.mode columnSELECT name, price, stock_quantity FROM products WHERE category_id = 1;SELECT first_name, last_name, city FROM customers WHERE state = 'CA';WHERE acts like a gatekeeper ā it evaluates each row against your condition and only lets matching rows through. The `=` operator checks for exact equality. Notice that text values must be wrapped in single quotes ('CA'), while numbers don't need quotes (1). This is because SQL distinguishes between string literals and numeric literals.
The first query returns only products in category 1. The second returns only customers whose state is 'CA'. Rows that don't match the condition are excluded entirely.