Skip to content

Instantly share code, notes, and snippets.

@deatheragetr
Last active December 18, 2015 04:09
Show Gist options
  • Save deatheragetr/5723476 to your computer and use it in GitHub Desktop.
Save deatheragetr/5723476 to your computer and use it in GitHub Desktop.
Amazon Schtuff :)
CREATE TABLE movies (
id int,
title varchar(255),
directors varchar(255),
actors text,
release_year int,
category varchar(255),
price int
);
CREATE TABLE reviews (
id int,
content text,
movie_id int
);
INSERT INTO movies (id, title, directors, actors, release_year, category, price)
VALUES
(1, "Hackers", "Iain Softley", "Johnny Lee Miller Angelina Jolie Jessie Bradford", 1998, "drama", 1979),
(2, "Titanic", "James Cameron", "Leonardo DiCaprio Kate Winslet", 7, "drama", 1249),
(3, "The Dark Knight", "Christopher Nolan", "Christian Bale Heath Ledger", 2008, "drama", 360),
(4, "The Dreamers", "Bernardo Bertolucci", "Michael Pitt Louis Garrel Eva Green", 2004, "foreign", 563),
(5, "Last Tango in Paris", "Bernardo Bertolucci", "Marlon Brando Maria Schneider", 1973, "foreign", 1249),
(6, "Jurassic Park", "Steven Spielberg", "Laura Dern Sam Neil Jeff Goldblum", 1993, "action", 996),
(7, "Octopussy", "John Glen", "Roger Moore Maude Adams", 1983, "action", 499),
(8, "Beetlejuice", "Tim Burton", "Michael Keaton Alec Baldwin Winona Ryder", 1988, "fantasy", 455),
(9, "Edward Scissorhands", "Tim Burton", "Johnny Depp Winona Ryder Dianne Wiest", 1998, "fantasy", 1979),
(10, "Spring Breakers", "Harmony Korine", "James Franco Vanessa Hudgens Selena Gomez", 2013, "action", 1496);
INSERT INTO reviews (id, content, movie_id)
VALUES
(1, "Mind Blowing Tingly Awesome Feelings", 4),
(2, "Banal, Shallow, and Pedantic", 4),
(3, "THE BUTTER SCENE WTF", 5),
(4, "I LOL'D", 10),
(5, "THAT SHIT CRAY", 9);
--------Answers to questions
#3
SELECT * FROM movies WHERE price in (SELECT MAX(price) FROM movies);
#4
SELECT SUM(price) FROM movies WHERE id = 2 OR id = 5;
#5
SELECT title FROM movies;
#8
SELECT reviews.content FROM movies, reviews, WHERE movies.id = 5 AND
reviews.movie_id = movies.id;
#9
SELECT * FROM reviews WHERE movie_id in (
SELECT movie_id FROM reviews
WHERE id = 1
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment