Created
March 8, 2021 08:22
-
-
Save bogoreh/6ef8747d09bc95696dc6a99aea0cd656 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Create a database of songs and artists */ | |
| CREATE TABLE artists ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| name TEXT, | |
| country TEXT, | |
| genre TEXT); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Taylor Swift", "US", "Pop"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Led Zeppelin", "US", "Hard rock"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Lata", "India", "Bollywood"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Queen", "UK", "Rock"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Celine Dion", "Canada", "Pop"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Meatloaf", "US", "Hard rock"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Garth Brooks", "US", "Country"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Shania Twain", "Canada", "Country"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Rihanna", "US", "Pop"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Guns N' Roses", "US", "Hard rock"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Gloria Estefan", "US", "Pop"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Bob Marley", "Jamaica", "Reggae"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Lata", "India", "Bollywood"); | |
| INSERT INTO artists (name, country, genre) | |
| VALUES ("Sunidhi", "India", "Bollywood"); | |
| CREATE TABLE songs ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| artist TEXT, | |
| title TEXT); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Taylor Swift", "Shake it off"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Rihanna", "Stay"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Celine Dion", "My heart will go on"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Celine Dion", "A new day has come"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Shania Twain", "Party for two"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Gloria Estefan", "Conga"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Led Zeppelin", "Stairway to heaven"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("ABBA", "Mamma mia"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Queen", "Bicycle Race"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Queen", "Bohemian Rhapsody"); | |
| INSERT INTO songs (artist, title) | |
| VALUES ("Guns N' Roses", "Don't cry"); | |
| /*In this first step, select the title of all the songs by the artist named 'Queen'. */ | |
| SELECT title | |
| FROM songs | |
| WHERE artist = "Queen" ; | |
| /*Step 2 | |
| Now you'll make a 'Pop' playlist. In preparation, select the name of all of the artists from the 'Pop' genre */ | |
| SELECT name | |
| FROM artists | |
| WHERE genre LIKE 'Pop' ; | |
| /*To finish creating the 'Pop' playlist, add another query that will select the title of all the songs from the 'Pop' artists. | |
| It should use IN on a nested subquery that's based on your previous query. */ | |
| SELECT title | |
| FROM songs | |
| WHERE artist | |
| LIKE (SELECT name FROM artists WHERE genre like 'Pop') ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment