Add lesson 1: Tables, rows and SELECT
3 changed files with 32 additions and 0 deletions
lessons/01-tables-rows-and-select/README.md ADDED
| @@ -0,0 +1,21 @@ | ||
| 1 | +# Lesson 1: Tables, rows and SELECT | |
| 2 | + | |
| 3 | +In this lesson you'll work through tables, rows and SELECT step by step, with short exercises after each idea. | |
| 4 | + | |
| 5 | +Full lesson: [https://glibcode.net/courses/sql-essentials/lessons/1](https://glibcode.net/courses/sql-essentials/lessons/1) | |
| 6 | + | |
| 7 | +## Files | |
| 8 | + | |
| 9 | +- `select.sql`: SELECT columns and expressions from one table | |
| 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 < select.sql | |
| 17 | +``` | |
| 18 | + | |
| 19 | +## Exercises | |
| 20 | + | |
| 21 | +See [exercises.md](exercises.md). Ask in the forum once you've tried. | |
lessons/01-tables-rows-and-select/exercises.md ADDED
| @@ -0,0 +1,5 @@ | ||
| 1 | +# Exercises: lesson 1 | |
| 2 | + | |
| 3 | +1. Find one thing in `select.sql` you could name better and rename it everywhere. | |
| 4 | +2. Look up one function or command the example uses in the official documentation. Note one option you didn't know. | |
| 5 | +3. Combine this lesson with the previous one: use something from both in a small program of your own. | |
lessons/01-tables-rows-and-select/select.sql ADDED
| @@ -0,0 +1,6 @@ | ||
| 1 | +-- Run setup/schema.sql and setup/seed.sql first | |
| 2 | +SELECT name, email | |
| 3 | +FROM customers; | |
| 4 | + | |
| 5 | +SELECT name, price, price * 1.2 AS price_with_tax | |
| 6 | +FROM products; | |