消除 sql select 中的特定空值

Eliminating specific null values in sql select

所以我正在尝试创建一份报告,生成最佳男性 and/or 最佳女性 nominations/winners。然而,当我 运行 我的 select 我得到所有没有获奖者或提名的电影。无法弄清楚如何摆脱空值。这是我的代码。顺便说一下,这是在 Oracle 中。

/*Oscar Nominations for Best Actor Report */
SELECT 
    movie.MVYEAR as "Movie Year", 
    movie.MVTITLE as "Movie Title",
    star.STARNAME as "Star Name", 
    movstar.BESTM as "Best Male", 
    movstar.BESTF as "Best Female"
FROM 
    movie, 
    star, 
    movstar
WHERE 
    star.STARNUM = movstar.STARNUM
AND 
    movie.MVNUM = movstar.MVNUM
ORDER BY movie.MVYEAR ASC;

但我的结果包含有获奖者和提名者的电影以及没有任何 winners/noms 的电影,导致查询显示空值。如何摆脱查询中显示的带有空值的 results/movies?

您需要添加一个 where 条件,但最好将联接与 where 子句分开。

      SELECT movie.MVYEAR as "Movie Year", 
             movie.MVTITLE as "Movie Title", 
             star.STARNAME as "Star Name", 
             movstar.BESTM as "Best Male", movstar.BESTF as "Best Female"
        FROM movie
  INNER JOIN movstar 
          ON movie.MVNUM = movstar.MVNUM
  INNER JOIN star
          ON star.STARNUM = movstar.STARNUM
       WHERE movstar.BESTM IS NOT NULL 
          OR movstar.BESTF IS NOT NULL
    ORDER BY movie.MVYEAR ASC;