左外联接与isull

时间:2019-11-15 10:23:32

标签: sql ms-access outer-join

这是一个非常简单的LEFT OUTER JOIN,但返回的行为零:

SELECT All_varieties.*,variety_join.*
FROM All_varieties LEFT JOIN 
     variety_join 
     ON All_varieties.varietyID = variety_join.varietyID
WHERE (variety_join.sourceID = Null);

但是,我正在使用查询 All_varieties

SELECT plant.plantName, plant.plantGenus, plant.plantSpecies, variety.varietyLatin, variety.varietyEnglish, variety.varietyID
FROM plant LEFT JOIN 
     variety 
     ON plant.plantID = variety.plantID;

查询 All_varieties 可能是问题所在吗?

表格: enter image description here

1 个答案:

答案 0 :(得分:2)

应为variety_join.sourceID is null而不是variety_join.sourceID = Null

SELECT All_varieties.*,variety_join.*
FROM All_varieties LEFT JOIN 
     variety_join 
     ON All_varieties.varietyID = variety_join.varietyID
WHERE variety_join.sourceID is Null