具有空/空值的MySQL连接不返回任何结果

具有空/空值的MySQL连接不返回任何结果,mysql,join,null,Mysql,Join,Null,我尝试选择性地返回一些值(如果存在),如果不存在,则返回集合的其余部分 SELECT people.first_name, countries1.name AS "Country1" FROM addressbook_people AS people JOIN root_countries AS countries1 ON people.country1 = countries1.id 在某些情况下,不会为人们提供任何价值。country1, 但是,如果其中一个没有提供任何结果 如何重新构造

我尝试选择性地返回一些值(如果存在),如果不存在,则返回集合的其余部分

SELECT people.first_name, countries1.name AS "Country1" 
FROM addressbook_people AS people
JOIN root_countries AS countries1 ON people.country1 = countries1.id
在某些情况下,不会为人们提供任何价值。country1,
但是,如果其中一个没有提供任何结果

如何重新构造此查询以仍返回people.first\u name 当人没有价值的时候。国家1?

就去做吧

SELECT people.first_name, countries1.name AS "Country1" 
FROM addressbook_people AS people
LEFT JOIN root_countries AS countries1 ON people.country1 = countries1.id

这将导致在
root\u countries
表的相应字段上返回
NULL

可能会将
JOIN
更改为
LEFT JOIN