title: How to use aliases with MySQL LEFT JOIN
body: <p>My original query is doing joins using the WHERE clause rather than JOIN. I realized that this was not returning movies that did not have any stars or genres did not show up so I think I have to do a LEFT JOIN in order to show every movie. Here is my original SQL:</p>
  
  <pre><code>SELECT *
  FROM movies m, stars s, stars_in_movies sm, genres g, genres_in_movies gm
  WHERE m.id = sm.movie_id
  AND sm.star_id = s.id
  AND gm.genre_id = g.id
  AND gm.movie_id = m.id
  AND m.title LIKE '%the%'
  AND s.first_name LIKE '%Ben%'
  ORDER BY m.title ASC
  LIMIT 5;
  </code></pre>
  
  <p>I tried to do a LEFT JOIN on movies I'm definitely doing something wrong.</p>
  
  <pre><code>SELECT *
  FROM movies m, stars s, stars_in_movies sm, genres g, genres_in_movies gm
  LEFT JOIN movies m1 ON m1.id = sm.movie_id
  LEFT JOIN movies m2 ON m2.id = gm.movie_id
  AND sm.star_id = s.id
  AND gm.genre_id = g.id
  ORDER BY m.title ASC
  LIMIT 5;
  </code></pre>
  
  <p>I get <code>ERROR 1054 (42S22): Unknown column 'sm.movie_id' in 'on clause'</code> so clearly I'm doing the join wrong, I just don't see what it is.</p>