Skip to content

Instantly share code, notes, and snippets.

@Shurlow
Last active April 6, 2017 17:59
Show Gist options
  • Save Shurlow/6622c550d2f554e59fcbbb7a427de421 to your computer and use it in GitHub Desktop.
Save Shurlow/6622c550d2f554e59fcbbb7a427de421 to your computer and use it in GitHub Desktop.
Interview Prep Solutions

SQL:

SELECT title FROM songs
INNER JOIN artist_songs ON songs.id = artist_songs.song_id
INNER JOIN artists ON artists.id = artist_songs.artist_id;

stretch: The above query reterns multiple rows (The same song repeated for each artist). How would you tell sql to only return 1 row for each song answer: add DISTINCT after SELECT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment