SQL PROBLEM I just need to write a single SQL query for each
SQL PROBLEM
I just need to write a single SQL query for each of the question. ERD diagram is up there.
1.Which movies were created by a company with \"films\" in its name. List the movie title and ID.
2.Which actresses have been in a movie with Daniel Radcliffe. List their name and nickname.
3.Which movies have been directed by directors who h@ve directed more than one movie starring Angelina Jolie. Return the movie n@me and director n@me.
4.Find directors who have directed movies containing at least one actor or actress who has starred in more than twenty movies. Sort by number of movies made by the director that fits this criteria.
5.Find directors who have directed movies containing only actors and actresses who have starred in more than two movies. Sort by the number of movies made by the directors fitting this criteria.
Solution
1.Which movies were created by a company with \"films\" in its name. List the movie title and ID.
Sql query: SELECT title.title, id FROM movie_companies,title WHERE movies_companies.id= company_name.id AND company_name.name LIKE %films%;
2.Which actresses have been in a movie with Daniel Radcliffe. List their name and nickname.
Sql query: SELECT name.name, aka_name.name FROM name,aka_name,cast_info ON cast_info.person_id= name.id WHERE cast_info.movie_id IN(SELECT movie_id FROM cast_info,name ON cast_info.person_id=name.person_id WHERE name.name=\"Daniel Radcliffe\") AND cast_info.role_id=(SELECT id from role_type where role=\"actresses\");
