GUIDE
How to use this quiz book
Each set holds five questions. Read prerequisites → question → expected output in order, solve it yourself, and only then open the model answer and explanation. Working it out in your head is fine, and so is writing the SQL out. The explanation lets you step through how the tables change at every stage of the query.
01How a session goes
- STEP 01Pick a themeIf you are unsure where to start, follow a learning course on the top page.
- STEP 02Solve five questionsEvery question carries its own prerequisites and input tables, so everything you need is on the page.
- STEP 03Check the explanationThe commented model answer and the table-transition visualizer show why the result looks the way it does.
- STEP 04Build a recordMarking a question “Solved” or “Review” updates the catalog, the courses, and the per-theme progress on the top page.
02Reading the catalog
The top page is a heading per theme followed by one row per set. From left to right a row shows volume-part, title, level, and progress.
JOIN8 sets · 5 questions each
1-1 is the first five questions of volume 1 and 1-2 the second five. Basic sets come before applied ones.
03Reading a question page
Below is a real question page. The accordions and the visualizer steps work right here.
Example: JOIN BASIC 1-1
INNER JOIN — Join Two Tables on a Common Key and Keep Only Rows Present in Both
A JOIN combines two tables horizontally based on a common key column (for example user_id). In a normalized database, user data lives in the users table and order data in the orders table, so a JOIN is required to retrieve related data together.
INNER JOIN is the simplest kind: it keeps only the rows whose key exists in both tables, per the ON clause. Rows whose key exists in just one table are dropped (an intersection).
SELECT columns, ... FROM left_table AS alias INNER JOIN right_table AS alias ON left_table.key = right_table.key;
AS o lets you write o.user_id, making it explicit that you mean "user_id of the orders table". When the same column name exists in several tables, alias qualification is mandatory.Join the orders table and the users table on user_id, and retrieve order_id, the user's name (name), and amount (the order amount).
Note: user_id = 4 in orders does not exist in users. And user_id = 3 (Yamada) in users has no orders.
| order_id | user_id | amount |
|---|---|---|
| 1 | 1 | 3000 |
| 2 | 2 | 5000 |
| 3 | 4 | 1200 |
| user_id | name |
|---|---|
| 1 | Tanaka |
| 2 | Sato |
| 3 | Yamada |
| order_id | name | amount |
|---|---|---|
| 1 | Tanaka | 3000 |
| 2 | Sato | 5000 |
SELECT o.order_id, u.name, -- the u. prefix states explicitly: the name column of the users table o.amount FROM orders AS o -- start from orders (the left table) INNER JOIN users AS u -- join with users (the right table) ON o.user_id = u.user_id -- match key: keep only rows whose user_id matches in both tables ORDER BY o.order_id; /* Execution order: 1. FROM orders AS o → the orders table 2. INNER JOIN users AS u → for each orders row, match and join the users rows satisfying ON 3. SELECT o.order_id, ... → project from the joined virtual table */
LEGEND
① FROM
FROM orders AS oRead the orders table (3 rows). The user_id column is the join key. Each of these rows will next be matched against the users table.| order_id | user_id | amount |
|---|---|---|
| 1 | 1 | 3000 |
| 2 | 2 | 5000 |
| 3 | 4 | 1200 |
On the real page, an illustrated walkthrough of the key points follows below this.
This figure is not a screenshot: it is built from the same HTML and CSS as a question page. Anything you do here is not saved to your learning record.
04Records and review
- Saved automaticallyMarks are stored in your browser and work without signing in.
- Across devicesSign in and your record syncs to your account, so you can continue on another device.
- Narrow to reviewThe “Review” filter (the bookmark chip) on the top page shows only the sets you marked for review.