-- all actors who were in a Romantic Comedy with Woody Allen that came out in 1999 or later
SELECT a2.first_name, a2.last_name, m.name
FROM actors a1
JOIN roles r1 ON r1.actor_id = a1.id
JOIN movies m ON m.id = r1.movie_id
JOIN roles r2 ON r2.movie_id = m.id
JOIN actors a2 ON a2.id = r2.actor_id
JOIN movies_genres mg1 ON mg1.movie_id = m.id
JOIN movies_genres mg2 ON mg2.movie_id = m.id
WHERE a1.first_name = "Woody"
  AND a1.last_name = "Allen"
  AND a1.id != a2.id
  AND mg1.genre = "Romance"
  AND mg2.genre = "Comedy"
  AND m.year >= 1999
ORDER BY m.name, a2.last_name, a2.first_name;
