-1

目标是显示所有没有视频的电影的电影编号、电影名称和电影年份。这是表格。首先是电影桌。

mv_no   mv_name                     mv_year mv_price mv_genre  p_code
1234    The Cesar Family Christmas  2009    39.95   FAMILY     2
1235    Smoke Mountain Wildfire     2006    59.95   ACTION     3
1236    Richard Goodhope            2010    59.95   DRAMA      2
1237    Beatnik Fever               2009    29.95   COMEDY     2
1238    Constant Companion          2010    89.95   DRAMA      2
1239    Where Hope Dies             2000    25.49   DRAMA      3
1245    Time to Burn                2006    45.49   ACTION     3
1246    What He Doesn't Know        2008    58.29   COMEDY     1
1250    The Girl With The Dragon Ta 2011    69.95   DRAMA      3
1251    X-Men: First Class          2011    39.95   ACTION     3
1252    Cape of Good Hope           2004    34.79   COMEDY     1
1253    We Bought A Zoo             2011    29.99   COMEDY     1
1258    Rebuilding Hope             2009    45.95   DRAMA      1  

然后是视频表:

vid_no  vid_indate  mv_no   v_status
34341   2008-09-04  1235    IN
34342   2008-09-04  1235    IN
34366   2013-03-02  1236    IN
34367   2013-03-02  1236    IN
34368   2013-03-02  1236    OUT
34369   2013-03-02  1236    IN
44392   2008-09-25  1237    IN
44397   2008-09-25  1237    IN
54321   2008-06-16  1234    IN
54324   2008-06-16  1234    OUT
54325   2008-06-16  1234    IN
59237   2008-09-25  1237    IN
61353   2013-03-02  1245    IN
61354   2008-09-25  1245    IN
61367   2008-09-25  1246    OUT
61369   2011-02-25  1246    IN
61388   2013-03-02  1239    IN
61399   2012-04-06  1250    IN
71233   2012-01-05  1251    IN
71235   2012-02-12  1252    IN
71246   2012-03-05  1253    IN
71255   2012-01-24  1258    IN
4

1 回答 1

1

这可以通过排除连接轻松完成:

SELECT movie.mv_no, movie.mv_name, movie.mv_year
FROM WhyDoesNoOneNameTheirTablesInSQLQuestions AS movie
LEFT OUTER JOIN NoReallyItMakeItSoMuchEasierToWriteAnswers AS video
 USING (mv_no)
WHERE video.movie_id IS NULL
于 2013-05-12T18:20:20.893 回答