w3resource
SQL exercises

SQL exercises on movie Database: Find 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

SQL movie Database: Join Exercise-2 with Solution

2. 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.

Sample table: actor


Sample table: movie_cast


Sample table: movie


Sample Solution:

SELECT act_fname,act_lname,role
  FROM actor 
	  JOIN movie_cast ON actor.act_id=movie_cast.act_id
		JOIN movie ON movie_cast.mov_id=movie.mov_id 
		  AND movie.mov_title='Annie Hall';

Sample Output:

      act_fname       |      act_lname       |              role
----------------------+----------------------+--------------------------------
 Woody                | Allen                | Alvy Singer
(1 row)

Practice Online


Movie database model

Query Visualization:

Duration:

Query visualization of Find 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 - Duration

Rows:

Query visualization of Find 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 - Rows

Cost:

Query visualization of Find 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 - Cost

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

Previous: Write a query in SQL to find the name of all reviewers who have rated their ratings with a NULL value.
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 for 'Eyes Wide Shut'.

What is the difficulty level of this exercise?



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