Filtering Data Using WHERE with AND Operator
📖 Scenario: You are working with a small store's database. The store wants to find products that are both affordable and in stock.
🎯 Goal: Build an SQL query that selects products with a price less than 20 and quantity greater than 0 using the WHERE clause with the AND operator.
📋 What You'll Learn
Create a table called
products with columns id, name, price, and quantity.Insert exactly these rows into
products: (1, 'Pen', 5, 10), (2, 'Notebook', 15, 0), (3, 'Eraser', 3, 5), (4, 'Backpack', 25, 3).Create a variable or placeholder for the price limit set to 20.
Write a SELECT query to get
name and price from products where price is less than the price limit and quantity is greater than 0 using WHERE with AND.Complete the query with a semicolon.
💡 Why This Matters
🌍 Real World
Filtering data with multiple conditions is common in business reports, inventory checks, and customer queries.
💼 Career
Knowing how to use WHERE with AND helps in writing precise database queries for data analysis and application development.
Progress0 / 4 steps