I’m a stuck with the 2nd exercice in last project of SQL course (querying tables):
“Smooth Criminal” is a track from Michael Jackson’s “Bad” album. Add this track to the database.
This code does work, but I have to check manually what is the album_id (in the albums table) :
INSERT INTO tracks(title, album_id) VALUES ('Smooth Criminal', 8) ;
I would like to do it automatically, more or less like this ( but this code does not work) :
INSERT INTO tracks(title, album_id) VALUES ('Smooth Criminal', SELECT id FROM albums WHERE name = 'Bad') ;
Does anyone know the correct syntax to do this operation ?
Thanks a lot.