📖 Worked Example: Building SQL Queries
Follow along as we build SQL queries step by step!
Reference: products table
| id | name | category | price | stock |
|---|---|---|---|---|
| 1 | Laptop | Electronics | 899.99 | 15 |
| 2 | Mouse | Electronics | 29.99 | 150 |
| 3 | Desk | Furniture | 249.99 | 25 |
| 4 | Chair | Furniture | 179.99 | 40 |
| 5 | Monitor | Electronics | 349.99 | 30 |
| 6 | Keyboard | Electronics | 79.99 | 85 |
Query Building Process
1
Identify what you need
What columns do you want? What conditions must be met?
2
Start with SELECT
List the columns you want, or use * for all.
3
Add FROM
Specify which table contains the data.
4
Add WHERE (if needed)
Filter results with conditions using =, >, <, AND, OR.