售票處要打一張訂單表:電影名、哪天、幾個座位。tickets 裡只有 movie_id,電影名在 movies 裡。把兩張表連起來,按順序選出 title、day、seats 三列。
idPKtitlegenreminutesratingidPKmovie_idFKdayseatspricetickets.movie_id → movies.id
| id | title | genre | minutes | rating |
|---|---|---|---|---|
| 1 | Robot Summer | family | 95 | 8 |
| 2 | Dark Lake | horror | 110 | 6 |
| 3 | Space Pals | family | 88 | 7 |
| 4 | The Long Road | drama | 142 | 9 |
| 5 | Laugh Track | comedy | 101 | 5 |
| 6 | Snow Day | comedy | 92 | 7 |
| id | movie_id | day | seats | price |
|---|---|---|---|---|
| 1 | 1 | Fri | 2 | 40 |
| 2 | 1 | Sat | 4 | 80 |
| 3 | 2 | Fri | 1 | 25 |
| 4 | 3 | Sat | 3 | 54 |
| 5 | 4 | Sun | 2 | 60 |
| 6 | 1 | Sun | 1 | 20 |
| 7 | 5 | Sat | 2 | 36 |
| 8 | 3 | Sun | 5 | 90 |
idPKtitlegenreminutesratingidPKmovie_idFKdayseatspricetickets.movie_id → movies.id
| id | title | genre | minutes | rating |
|---|---|---|---|---|
| 1 | Robot Summer | family | 95 | 8 |
| 2 | Dark Lake | horror | 110 | 6 |
| 3 | Space Pals | family | 88 | 7 |
| 4 | The Long Road | drama | 142 | 9 |
| 5 | Laugh Track | comedy | 101 | 5 |
| 6 | Snow Day | comedy | 92 | 7 |
| id | movie_id | day | seats | price |
|---|---|---|---|---|
| 1 | 1 | Fri | 2 | 40 |
| 2 | 1 | Sat | 4 | 80 |
| 3 | 2 | Fri | 1 | 25 |
| 4 | 3 | Sat | 3 | 54 |
| 5 | 4 | Sun | 2 | 60 |
| 6 | 1 | Sun | 1 | 20 |
| 7 | 5 | Sat | 2 | 36 |
| 8 | 3 | Sun | 5 | 90 |
-- 在這裡寫:用 JOIN 連上 movies,選出 movies.title、tickets.day、tickets.seats SELECT day, seats FROM tickets;
寫好了先點「執行」看看結果,沒問題再點「提交」。