Database Reference
In-Depth Information
Figure 10.22
A Barebones Self-
Join on the
CDTRACK Table.
COLUMN SONG FORMAT A36 HEADING "Song"
SELECT CD.TITLE AS CD, T.TRACK_SEQ_NO AS TRACK
, S.TITLE AS SONG
FROM SONG S, CDTRACK T, MUSICCD CD, ARTIST A
WHERE A.NAME = 'Sheryl Crow'
AND A.ARTIST_ID = S.ARTIST_ID
AND S.SONG_ID = T.SONG_ID
AND T.MUSICCD_ID = CD.MUSICCD_ID
ORDER BY CD, SONG;
Including the CD and song titles in Figure 10.23 makes it easier to see
how the query works. The CD called “The Best of Sheryl Crow” has six
songs. Two of the songs are from the “Soak Up the Sun” CD and four of the
songs are from the “C'mon, C'mon” CD.
 
Search WWH ::




Custom Search