SQL exercises on movie Database: Find all the movies with year, genres, and name of the director
SQL movie Database: Join Exercise-8 with Solution
8. Write a query in SQL to list all the movies with year, genres, and name of the director.
Sample table: movie
Sample table: genres
Sample table: movie_genres
Sample table: director
Sample table: movie_direction
Sample Solution:
SELECT mov_title, mov_year, gen_title, dir_fname, dir_lname
FROM movie
NATURAL JOIN movie_genres
NATURAL JOIN genres
NATURAL JOIN movie_direction
NATURAL JOIN director;
Sample Output:
mov_title | mov_year | gen_title | dir_fname | dir_ ----------------------------------------------------+----------+----------------------+----------------------+---------- Vertigo | 1958 | Mystery | Alfred | Hitchcock The Innocents | 1961 | Horror | Jack | Clayton Lawrence of Arabia | 1962 | Adventure | David | Lean The Deer Hunter | 1978 | War | Michael | Cimino -- More --
Practice Online

Query Visualization:
Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to list all the movies with year and genres.
Next: Write a query in SQL to list all the movies with title, year, date of release, movie duration, and first and last name of the director which released before 1st January 1989, and sort the result set according to release date from highest date to lowest.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework