Add lesson 2: Filtering with WHERE

Mira Kovac 1 year ago
parent 4b4a6721c5 commit 90068c8f2490811ff3f038fa8f0c67264fc1083a
3 changed files with 35 additions and 0 deletions
+21-0lessons/02-filtering-with-where/README.md ADDED
@@ -0,0 +1,21 @@
1+# Lesson 2: Filtering with WHERE
2+
3+This lesson covers filtering with WHERE. You'll read a short explanation, try three small exercises and finish with a quiz.
4+
5+Full lesson: [https://glibcode.net/courses/sql-essentials/lessons/2](https://glibcode.net/courses/sql-essentials/lessons/2)
6+
7+## Files
8+
9+- `where.sql`: filtering rows with WHERE, AND, IN and LIKE
10+
11+## Run it
12+
13+```sh
14+sqlite3 shop.db < ../../setup/schema.sql
15+sqlite3 shop.db < ../../setup/seed.sql
16+sqlite3 shop.db < where.sql
17+```
18+
19+## Exercises
20+
21+See [exercises.md](exercises.md). Ask in the forum once you've tried.
+5-0lessons/02-filtering-with-where/exercises.md ADDED
@@ -0,0 +1,5 @@
1+# Exercises: lesson 2
2+
3+1. What happens with an empty input? Change the code so it handles that case with a clear message.
4+2. Add a comment above each block explaining what it does, in your own words.
5+3. Explain the example to someone who hasn't taken the course. Which part was hardest to explain?
+9-0lessons/02-filtering-with-where/where.sql ADDED
@@ -0,0 +1,9 @@
1+SELECT name, city
2+FROM customers
3+WHERE city = 'Lisbon';
4+
5+SELECT name, price
6+FROM products
7+WHERE price BETWEEN 10 AND 50
8+ AND category IN ('books', 'games')
9+ AND name LIKE '%guide%';