Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created July 30, 2019 16:18
Show Gist options
  • Save krokrob/186b1b8101b30a635c4c3731dd6909e5 to your computer and use it in GitHub Desktop.
Save krokrob/186b1b8101b30a635c4c3731dd6909e5 to your computer and use it in GitHub Desktop.
-- QUIZZ DB & ActiveRecord
-- Q1 A bunch of tables contining data connected between each other through a system of primary(id)/foreign keys(xxxxx_id)
-- Q2 1:N
-- N:N
-- 1:1
-- Q5 SQL
-- Q6
SELECT *
FROM books
WHERE publishing_year < 1985
-- Q7
SELECT b.id, b.title, b.publishing_year
FROM books b
JOIN authors a ON a.id = b.author_id
WHERE a.name = 'Jules Verne'
ORDER BY b.publishing_year DESC
LIMIT 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment