I need to get data from 3 different tables. I know the basics about JOINs but when it comes to more complicated queries like getting data from 3 or more tables using JOIN I get a little confused and I just start playing with the queries writing what make sense to me, like the next one:
SELECT movies.imdbID,
movies.title,
movies.year,
movie_ratings.votes,
movie_ratings.total_value,
movie_ratings_external.votes,
movie_ratings_external.total_value
FROM movies, movie_ratings_external
LEFT JOIN movie_ratings ON movie_ratings.imdbID = movie_ratings_external.imdbID
WHERE movies.imdbID = movie_ratings_external.imdbID
ORDER BY movie_ratings.votes DESC, movie_ratings_external.votes DESC
LIMIT 30
This query works. I get the selected fields from the correct tables and ordered the right way, but I think I'm mixing up things (like regular querying two tables and JOINing between two tables) and I'm sure theres a better/more efficient way to accomplish the same purpouse.
Any DB geek available?