Skip to content
Advertisement

MYSQL: Identify the five actors who share the greatest number of films with Nick Wahlberg (Sakila Database)

table 1: film_actor contains:

table 2: actor contains

I have tried:

I realize I am probably very off.

Advertisement

Answer

Breaking it down, you’d want to start with all the movies that nick starred in:

The actor_id field will become important later

Subsequently, you’d want to find the actors that starred in that list of movies, but aren’t nick. For that you can join against an uncorrelated subquery:

Finally, you perform the grouping and ordering:

Fiddle

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement