48. Movie and TV actors

easy

Instruction

  • Write a query to return actors who appeared in both tv and movies
  • The order of your results doesn't matter.
  • You need to use INNER JOIN.

Table 1: actor_movie

Actors who appeared in a movie.

  col_name  | col_type
------------+-------------------
 actor_id   | integer
 first_name | character varying
 last_name  | character varying

Table 2: actor_tv

Actors who appeared in a TV show.

  col_name  | col_type
------------+-------------------
 actor_id   | integer
 first_name | character varying
 last_name  | character varying

Sample results

 actor_id | first_name  |  last_name
----------+-------------+-------------
        1 | PENELOPE    | GUINESS
        4 | JENNIFER    | DAVIS

Expected results

Solution postgres

SELECT 
    M.actor_id,
    M.first_name, 
    M.last_name
FROM actor_movie M
INNER JOIN actor_tv T
ON T.actor_id = M.actor_id;
    

Explanation

This query selects the actor ID, first name, and last name from two tables: "actor_movie" and "actor_tv". It then joins these two tables on the "actor_id" column to only show actors who have worked in both movies and TV shows.



More INNER JOIN questions

ID Title Level FTPR
179 Members who ever moved from Microsoft to Google linkedin medium
35%
162 Number of orders per brand walmart easy
40%
150 Countries with above average customers social easy
10%
99 Page recommendation social medium
12%
91 same day friend request acceptance rate spotify easy
11%
50 Top 5 cities for movie rentals easy
23%
49 Top 3 money making movie categories medium
19%
40 Top 2 most rented movie in June 2020 medium
15%
39 Most productive actor with inner join easy
23%
38 Most popular movie category (name and id) medium
18%
37 Most popular movie category easy
17%
36 Actors from film 'AFRICAN EGG' easy
36%