Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Substitua NOT IN por LEFT JOIN na instrução SQL


Tente isto:
SELECT m.director 
FROM movies m
LEFT JOIN stars_in_movies sm ON m.id = sm.movie_id
WHERE sm.movie_id IS NULL 
AND sm.star_id = %s

a segunda consulta
  SELECT first_name, last_name
  FROM stars s
  LEFT JOIN stars_in_movies sm
  ON sm.star_id = s.id
  WHERE sm.star_id IS NULL
  AND star_id = %s