0

I'm having trouble solving the following SQL requests:

1) "Give the original name and year, also the current name and year, and the studio of the films that were made before '1960' then remade after '2000'."

2) "Get the filmname of all films created before ‘1951’ and remade after ‘2000’"

There are several tables but I'm assuming that only 2 are needed: 'films' and 'remakes'

'films' attributes: filmid, filmname, year, director, studio

'remakes' attributes: filmid, title, year, priorfilm, prioryear

My understanding is that remakes are included in films so the priorfilm in 'remakes' table corresponds to a filmid in the 'films' table. I'm having trouble linking the two to be able to place the year conditions.

4

2 に答える 2

0

最初のクエリ

SELECT f.filmname, f.year, f.studio, r.title, r.prioryear
       from film f , join remakes r on f.filmid = r.filmid
            where r.year > 2000 and f.year < 1960;

2 番目のクエリ

select f.* from film f join remakes r on f.filmid = r.filmid
    where f.year < 1951 and r.year > 2000
于 2012-11-07T16:37:54.210 に答える
0

films(オリジナルの場合)remakes(映画がどのように対応しているかがわかります)に参加し、次にfilms(リメイク版の場合)に参加する必要があります。

1:

SELECT o.filmname as originalname, o.year as originalyear,
       c.filmname as remakename, c.year as remadeyear, o.studio
FROM films o
INNER JOIN remakes r on r.priorfilm = o.filmid
INNER JOIN films c on c.filmid = r.filmid
WHERE o.year < 1960 AND c.year > 2000

2:

SELECT o.filmname
FROM films o
INNER JOIN remakes r on r.priorfilm = o.filmid
INNER JOIN films c on c.filmid = r.filmid
WHERE o.year < 1951 AND c.year > 2000
于 2012-11-07T16:30:15.413 に答える