title: SQLzoo more JOIN execerise #16
body: <p>I am working on the more JOIN operations with the movie database. My question is on problem #16: List all the people who have worked with 'Art Garfunkel'</p>
  
  <p>You need to first fetch all movies in which Art Garfunkel is in as one value and then fetch all the names of people who were in the same movies by comparing it to the first value.</p>
  
  <p>I came up with my own query and by logic it is supposed to work but does not due to a timeout (which I am assuming is due to an inefficient query)</p>
  
  <p>My query: </p>
  
  <pre><code>SELECT DISTINCT a.name
  FROM actor a
  JOIN casting b ON (a.id=b.actorid) 
  JOIN movie c ON (b.movieid=c.id)
  WHERE c.title IN(SELECT z.title
  FROM movie z
  JOIN casting y ON (z.id=y.movieid)
  JOIN actor x on (y.actorid=x.id)
  WHERE x.name='Art Garfunkel')
  </code></pre>
  
  <p>Another version:</p>
  
  <pre><code>SELECT DISTINCT actor.name
  FROM movie,actor,casting
  WHERE movie.id=casting.movieid
  AND actor.id=casting.actorid
  AND movie.title IN(SELECT movie.title
  FROM movie,actor,casting
  WHERE movie.id=casting.movieid
  AND actor.id=casting.actorid
  AND actor.name='Art Garfunkel')
  </code></pre>
  
  <p>Both of these throw a parse error saying that there was a timeout attempting to query whatever is shown above.</p>
  
  <p>The version of query they provided that was accepted as an answer is:</p>
  
  <pre><code>SELECT DISTINCT d.name
  FROM actor d JOIN casting a ON (a.actorid=d.id)
     JOIN casting b ON (a.movieid=b.movieid)
     JOIN actor c ON (b.actorid=c.id 
                  AND c.name='Art Garfunkel')
    WHERE d.id!=c.id
  </code></pre>
  
  <p>Is my logic entirely wrong here? Or is it that the query is simply very very inefficient (which I am thinking). Is there a way to fix it to run and get the correct answer? Or should I be thinking more logically the way the correct query does it?</p>
  
  <p>So many questions but I wanted feedback on why that query did not work and what the next step is.</p>