Multi-row and multi-column subqueries assessment q2

Screen Link:
Subqueries As Lists Or Tables Assessment | Dataquest

My Code:

SELECT t.name, t.composer, t.genre_id, t.media_type_id
  FROM track AS t
 WHERE t.composer IS NOT NULL
   AND t.genre_id = (SELECT g.genre_id
                       FROM genre AS g
                      WHERE g.name LIKE '%Rock%'
                         OR name LIKE '%Metal%')
   AND t.media_type_id = (SELECT m.media_type_id
                            FROM media_type AS m
                           WHERE m.name LIKE '%AAC Audio%');

What I expected to happen:

I think it is working because I tested each individual subquery and its getting the right information, but I don’t know what the error is. I even tried showing SELECT * but it is not working.

What actually happened:

Hi @david.joseph.clarke:

Do you mind providing a screen link as per these guidelines so that we can better assist? Thanks!

Sorry about that, I must have accidentally deleted it when I was putting together my post before submitting it. Its back in there now! :slight_smile:

1 Like

I have solved it:

SELECT t.name, t.composer, t.genre_id, t.media_type_id
  FROM track AS t
 WHERE t.composer IS NOT NULL
   AND t.genre_id IN (SELECT g.genre_id
                       FROM genre AS g
                      WHERE g.name LIKE '%Rock%'
                         OR name LIKE '%Metal%')
   AND t.media_type_id IN (SELECT m.media_type_id
                            FROM media_type AS m
                           WHERE m.name LIKE '%AAC Audio%');

I was too quick and forgot to use IN with my collections, rather than =. This works and I’ll leave it up, in case anybody else has trouble with this assignment!

1 Like