I can't seem to wrap my mind around this query. I'm not sure if it's even possible.
I have a personal Movie Database and I'm trying to write an SQL Query which will do the following:
When given two different movie titles, I would like the query to find a third movie title (if it exists) that contains an actor from each of the first two.
For example, if I were to enter the movies "Seven" and "American History X", I would like to have the query return "Fight Club" (because Brad Pitt from 'Seven' and Edward Norton from 'American History X' are each in it), also, it would return "Runaway Jury" because Leland Orser from 'Seven' and Guy Torry from 'American History X' were both in that one.
Here is the relevant table information:
TABLE: Movies
FIELDS: MovieID, Title
TABLE: StarredIn
FIELDS: MovieID, ActorID
TABLE: Actors
FIELDS: ActorID, ActorName
Please let me know if this is possible and if so, how to accomplish it. I'd like to handle it in one SQL statement rather than code.
Thanks.
I have a personal Movie Database and I'm trying to write an SQL Query which will do the following:
When given two different movie titles, I would like the query to find a third movie title (if it exists) that contains an actor from each of the first two.
For example, if I were to enter the movies "Seven" and "American History X", I would like to have the query return "Fight Club" (because Brad Pitt from 'Seven' and Edward Norton from 'American History X' are each in it), also, it would return "Runaway Jury" because Leland Orser from 'Seven' and Guy Torry from 'American History X' were both in that one.
Here is the relevant table information:
TABLE: Movies
FIELDS: MovieID, Title
TABLE: StarredIn
FIELDS: MovieID, ActorID
TABLE: Actors
FIELDS: ActorID, ActorName
Please let me know if this is possible and if so, how to accomplish it. I'd like to handle it in one SQL statement rather than code.
Thanks.