Objective JOIN data in the tables created in the music database from Lab 3. Practice using
JOIN statements and understand some more complex queries
Introduction Follow the instructions to combine data from the tables created in Lab 3 using
JOINs and complex queries.
A join is a SELECT statement that combines data from two tables, known as the left table and
right table, into a single result.
An inner join selects only matching left and right table rows.
A left join selects all left table rows, but only matching right table rows.
A right join selects all right table rows, but only matching left table rows.
A full join selects all left and right table rows, regardless of match.
Hints:
1. Some questions can be solved in multiple ways and there will likely be variance in how
you and your peers answer some of the questions!
2. Take note of the name of each column as you complete the lab. Pay close attention which
tables contain which columns
3. Make sure that the type of JOIN you are using is the intended JOIN as they can have very
similar results; however, have vastly differently implications and reasons for reaching
this point.
Steps:
1) Write a query that JOINS two tables and uses a subquery to list the songs made by artists
over the age of 50. Your query should show the name of the song, the name of the artist, the
song length, and release date. For the column headers in the output rename song_name to
Title, artist to Artist, duration to Length, and release_date to Release Year
Your output should look like this
Title Artist Length Release Year
Where Does My Heart Beat
Now Celine Dion 4.33 1990
The Last to Know Celine Dion 4.36 1990
Have a Heart Celine Dion 4.16 1991
Candle in the Wind 1997 Elton John 3.59 1997
All I want for Christmas Is You Mariah Carey 4.01 1994
La Voce Del Silenzio Andrea Bocelli 4.55 2007
Just the Two of Us Will Smith 5.15 1997
2) Write a query that JOINS all tables to display the data as shown in the music_basic Note: You
are not using the music_basic table, but rather Joining the artists, genre, album, and songs tables
to output a table in the same format. Modify your column headers to produce a table that looks
like this:
(Hint: SELECT * FROM music_basic to get an idea for how your output should look. There are
multiple ways to do this!)
Id Title Artist Genre Length Release Year Album
1
Where Does
My Heart
Beat Now
Celine Dion Pop 4.33 1990 Unison
2 The Last to
Know Celine Dion Pop 4.36 1990 Unison
3 Never
Really Over Katy Perry EDM 3.43 2019 Single
4 Call Me
Maybe Katy Perry Pop 3.13 2011 Now 27
5 Have a
Heart Celine Dion Pop 4.16 1991 Unison
... ..... .... .... .... .... ....
3) Create a View table using the query created in Question 6 and 7. Display the contents of the
view table and include the results in your screenshot.
4) Using a complex query and the newly created MusicBasicView, find the artists HAVING at
least two songs in a genre
Example
Blake Shelton has 3 songs in country and therefore meets this criterion .
Objective JOIN data in the tables created in the music dat.pdf
1. Objective JOIN data in the tables created in the music database from Lab 3. Practice using
JOIN statements and understand some more complex queries
Introduction Follow the instructions to combine data from the tables created in Lab 3 using
JOINs and complex queries.
A join is a SELECT statement that combines data from two tables, known as the left table and
right table, into a single result.
An inner join selects only matching left and right table rows.
A left join selects all left table rows, but only matching right table rows.
A right join selects all right table rows, but only matching left table rows.
A full join selects all left and right table rows, regardless of match.
Hints:
1. Some questions can be solved in multiple ways and there will likely be variance in how
you and your peers answer some of the questions!
2. Take note of the name of each column as you complete the lab. Pay close attention which
tables contain which columns
3. Make sure that the type of JOIN you are using is the intended JOIN as they can have very
similar results; however, have vastly differently implications and reasons for reaching
this point.
Steps:
1) Write a query that JOINS two tables and uses a subquery to list the songs made by artists
over the age of 50. Your query should show the name of the song, the name of the artist, the
song length, and release date. For the column headers in the output rename song_name to
Title, artist to Artist, duration to Length, and release_date to Release Year
Your output should look like this
Title Artist Length Release Year
Where Does My Heart Beat
Now Celine Dion 4.33 1990
The Last to Know Celine Dion 4.36 1990
Have a Heart Celine Dion 4.16 1991
Candle in the Wind 1997 Elton John 3.59 1997
All I want for Christmas Is You Mariah Carey 4.01 1994
La Voce Del Silenzio Andrea Bocelli 4.55 2007
Just the Two of Us Will Smith 5.15 1997
2) Write a query that JOINS all tables to display the data as shown in the music_basic Note: You
are not using the music_basic table, but rather Joining the artists, genre, album, and songs tables
to output a table in the same format. Modify your column headers to produce a table that looks
like this:
(Hint: SELECT * FROM music_basic to get an idea for how your output should look. There are
multiple ways to do this!)
Id Title Artist Genre Length Release Year Album
1
Where Does
2. My Heart
Beat Now
Celine Dion Pop 4.33 1990 Unison
2 The Last to
Know Celine Dion Pop 4.36 1990 Unison
3 Never
Really Over Katy Perry EDM 3.43 2019 Single
4 Call Me
Maybe Katy Perry Pop 3.13 2011 Now 27
5 Have a
Heart Celine Dion Pop 4.16 1991 Unison
... ..... .... .... .... .... ....
3) Create a View table using the query created in Question 6 and 7. Display the contents of the
view table and include the results in your screenshot.
4) Using a complex query and the newly created MusicBasicView, find the artists HAVING at
least two songs in a genre
Example
Blake Shelton has 3 songs in country and therefore meets this criterion for the country genre;
Drake only has 1 R&B song so he would not meet this criterion for the R&B genre; however,
he does for Hip-Hop
Your output should list all the songs the artist has in the genre. Include only the artist's name,
genres, and song title columns (3 columns). (Hint: use HAVING)
Your output should look something like this:
Artist Title Genre
Beyonce Me, Myself and I R&B
Beyonce That's How you Like
It R&B
Beyonce Speechless R&B
Taylor Swift the 1 Alternative
Taylor Swift My Tears Ricochet Alternative
Taylor Swift cardigan Alternative
Drake Headlines Hip-Hop
Drake Marvins Room R&B
Drake Under Ground Kings Hip-Hop
Drake We'll Be Fine Hip-Hop
Eminem Love The Way You
Lie Hip-Hop
Eminem Not Afraid Hip-Hop
Eminem Almost Famous Hip-Hop
Thomas Rhett Make Me Wanna Country
Thomas Rhett Die a Happy Man Country
Blake Shelton Crash and Burn Country
3. Blake Shelton Heavy Liftin' Country
Blake Shelton The Dreamer Country
5) Modify your query from question 8 to only include records where the Genre is not Pop and
sort the output by artist name in descending order