INNER JOIN(II)
接下來,你會繼續練習 INNER JOIN。和上一題一樣使用 album 資料表,但這次要把它和新的 artist 資料表做連接。artist 有兩個欄位:artist_id 和 name。
本練習屬於課程
SQL Server 入門
練習說明
- 從
album(主要來源資料表)選取album_id與title欄位。 - 從
artist選取name欄位,並將其別名設為artist。 - 找出
album與artist之間的共同欄位,並進行 INNER JOIN。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
-- Select album_id and title from album, and name from artist
SELECT
___,
___,
___ AS artist
-- Enter the main source table name
FROM ___
-- Perform the inner join
INNER JOIN ___ on ___.___ = ___.artist_id;