Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ifrah Shahid
lab-exercises
Commits
ea7c5d07
Commit
ea7c5d07
authored
Nov 04, 2016
by
Sorrel Harriet
Browse files
fixing minor discrepencies
parent
57730b93
Changes
3
Hide whitespace changes
Inline
Side-by-side
lab-3/music-store-app/sql/queries.sql
100644 → 100755
View file @
ea7c5d07
...
...
@@ -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
...
...
lab-5/music-store-app/index.php
View file @
ea7c5d07
...
...
@@ -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
...
...
lab-5/music-store-app/sql/queries.sql
View file @
ea7c5d07
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment