w3resource
SQL exercises

SQL exercises on movie Database: Find the name of movie and director who directed a movie that casted a role for 'Eyes Wide Shut'

SQL movie Database: Join Exercise-3 with Solution

3. Write a query in SQL to find the name of movie and director (first and last names) who directed a movie that casted a role for 'Eyes Wide Shut'.

Sample table: director


Sample table: movie_direction


Sample table: movie_cast


Sample table: movie


Sample Solution:

SELECT dir_fname, dir_lname, mov_title
FROM  director 
NATURAL JOIN movie_direction
NATURAL JOIN movie
NATURAL JOIN movie_cast
WHERE role IS  NOT NULL
AND mov_title='Eyes Wide Shut';

Sample Output:

      dir_fname       |      dir_lname       |                     mov_title

----------------------+----------------------+----------------------------------
 Stanley              | Kubrick              | Eyes Wide Shut
(1 row)

Practice Online


Movie database model

Query Visualization:

Duration:

Query visualization of Find the name of movie and director who directed a movie that casted a role for 'Eyes Wide Shut' - Duration

Rows:

Query visualization of Find the name of movie and director who directed a movie that casted a role for 'Eyes Wide Shut' - Rows

Cost:

Query visualization of Find the name of movie and director who directed a movie that casted a role for 'Eyes Wide Shut' - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to list the first and last names of all the actors who were cast in the movie 'Annie Hall', and the roles they played in that production.
Next: Write a query in SQL to find the name of movie and director (first and last names) who directed a movie that casted a role as Sean Maguire.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming