Mysql
 sql >> Database >  >> RDS >> Mysql

Sostituisci NOT IN con LEFT JOIN nell'istruzione SQL

Prova questo:

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

la seconda domanda

  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