Last active
November 11, 2015 01:38
-
-
Save mrcsparker/7dd4dc8579ed65d7b4d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'movieId', | |
'movieTitle', | |
'movieYear', | |
'genreName', | |
'imdbId', | |
'tmdbId', | |
'rating', | |
'ratingTimestamp', | |
'ratingUserId' | |
UNION | |
SELECT | |
movies.id AS movieId, | |
movies.title AS movieTitle, | |
movies.year AS movieYear, | |
genres.name AS genreName, | |
links.imdb_id AS imdbId, | |
links.tmdb_id AS tmdbId, | |
ratings.rating AS rating, | |
ratings.timestamp AS ratingTimestamp, | |
ratings.user_id AS ratingUserId | |
FROM movies | |
INNER JOIN movie_genres ON | |
movie_genres.movie_id = movies.id | |
INNER JOIN genres ON | |
movie_genres.genre_id = genres.id | |
INNER JOIN links ON | |
links.movie_id = movies.id | |
INNER JOIN ratings ON | |
ratings.movie_id = movies.id | |
INTO outfile '/tmp/movie_ratings.csv' | |
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' | |
LINES TERMINATED BY '\n' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment