w3resource
SQL exercises

SQL exercises on movie Database: Find the actors with all information who played a role in the movie 'Annie Hall'

SQL movie Database: Subquery Exercise-1 with Solution

1. Write a query in SQL to list all the information of the actors who played a role in the movie 'Annie Hall'.

Sample table: actor


Sample table: movie_cast


Sample table: movie


Sample Solution:

SELECT * 
FROM actor 
WHERE act_id IN(
SELECT act_id 
FROM movie_cast 
WHERE mov_id IN (
SELECT mov_id 
FROM movie 
WHERE mov_title='Annie Hall'
));

Sample Output:

 act_id |      act_fname       |      act_lname       | act_gender
--------+----------------------+----------------------+------------
    111 | Woody                | Allen                | M
(1 row)

Practice Online


Movie database model

Query Visualization:

Duration:

Query visualization of Find the actors with all information who played a role in the movie 'Annie Hall' - Duration

Rows:

Query visualization of Find the actors with all information who played a role in the movie 'Annie Hall' - Rows

Cost:

Query visualization of Find the actors with all information who played a role in the movie 'Annie Hall' - Cost

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

Previous: SQL SUBQUERIES Exercises on movie Database
Next: Write a query in SQL to find the name of the director (first and last names) who directed a movie that casted a role for 'Eyes Wide Shut'.

What is the difficulty level of this exercise?



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