Database Reference
In-Depth Information
Figure 4.9
A Join Query.
name sequence present in both tables. In this case, the natural join con-
nected the two tables by matching values in the ARTIST_ID column found
in both tables.
SELECT NAME, TITLE FROM ARTIST NATURAL JOIN SONG;
4.2.6
Subquery
The query containing the subquery shown in Figure 4.10 returns the same
rows as the join query shown in Figure 4.9 but with only the title of the
song. A subquery cannot be used to display values in the results set unless
using a FROM clause embedded subquery, also known as an inline view.
SELECT TITLE FROM SONG WHERE ARTIST_ID IN
( SELECT ARTIST_ID FROM ARTIST );
4.2.7
Table or View Creation Query
We can create a new table using the join query from Figure 4.9. Selecting
the data from the new view would produce the same result as the query in
Figure 4.9:
CREATE VIEW SONGS AS
SELECT NAME, TITLE FROM ARTIST NATURAL JOIN SONG;
 
Search WWH ::




Custom Search