

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Subqueries
incomplete
2: Subqueries
incomplete
3: Query Practice – Invoice Subquery
incomplete
4: No Tables
incomplete
5: Quiz
incomplete
This lesson's interactive features are locked, please to keep using them
Let's trace how the two SELECT statements work together in the song example:
SELECT
id,
song_name,
artist_id
FROM
songs
WHERE
artist_id IN (
SELECT
id
FROM
artists
WHERE
artist_name LIKE 'Rick%'
);
Rick.artist_id matches any of those IDs.So the inner query supplies the values for IN to check. Even if it finds just one artist, there could be many songs that belong to them.
The row-count question refers to the result of the whole query.