Skip to content

Instantly share code, notes, and snippets.

-- Part 1: Basic JOINs
-- 1. List all album names with their artist names (use appropriate through table)
SELECT
al.name AS album_name,
ar.name AS artist_name
FROM
albums al
JOIN r_albums_artists raa ON raa.album_id = al.id
JOIN artists ar ON ar.id = raa.artist_id
ORDER BY
-- Part 1: Basic Queries
-- 1. Find the 10 longest books (by pages) in the database
select
*
from
books
where
pages is not null
order by
pages desc