Commit ea7c5d07 authored by Sorrel Harriet's avatar Sorrel Harriet
Browse files

fixing minor discrepencies

parent 57730b93
......@@ -28,6 +28,7 @@ INNER JOIN Artist
ON Album.artist_id=Artist.id
INNER JOIN Genre
ON Album.genre_id=Genre.id
GROUP BY title /* group by album title to avoid duplicate rows */
ORDER BY title ASC;
/* 1c. Retrieve a list of Albums
......@@ -37,8 +38,6 @@ Include ALL albums, even those without tracks.
Order by title (a-z) */
SELECT Album.title, Album.price, Artist.first_name, Artist.last_name, Genre.name AS genre, (SELECT COUNT(*) FROM Track WHERE Album.upc=Track.album_upc) AS num_tracks
FROM Album /* notice the nested query, aggregate function and aliases! */
LEFT JOIN Track /* LEFT JOIN causes all Albums to be returned, even when no matching record in Track table */
ON Album.upc=Track.album_upc
INNER JOIN Artist
ON Album.artist_id=Artist.id
INNER JOIN Genre
......
......@@ -17,7 +17,6 @@ if (mysqli_connect_errno()) {
// define the SQL query to run (from lab 3!)
$sql = "SELECT Album.title, Album.price, Artist.first_name, Artist.last_name, Genre.name AS genre, (SELECT COUNT(*) FROM Track WHERE Album.upc=Track.album_upc) AS num_tracks FROM Album
LEFT JOIN Track ON Album.upc=Track.album_upc
INNER JOIN Artist
ON Album.artist_id=Artist.id
INNER JOIN Genre
......
......@@ -28,6 +28,7 @@ INNER JOIN Artist
ON Album.artist_id=Artist.id
INNER JOIN Genre
ON Album.genre_id=Genre.id
GROUP BY title /* group by album title to avoid duplicate rows */
ORDER BY title ASC;
/* 1c. Retrieve a list of Albums
......@@ -37,8 +38,6 @@ Include ALL albums, even those without tracks.
Order by title (a-z) */
SELECT Album.title, Album.price, Artist.first_name, Artist.last_name, Genre.name AS genre, (SELECT COUNT(*) FROM Track WHERE Album.upc=Track.album_upc) AS num_tracks
FROM Album /* notice the nested query, aggregate function and aliases! */
LEFT JOIN Track /* LEFT JOIN causes all Albums to be returned, even when no matching record in Track table */
ON Album.upc=Track.album_upc
INNER JOIN Artist
ON Album.artist_id=Artist.id
INNER JOIN Genre
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment