谁从外键返回一个值为null而不是null

时间:2017-10-11 22:35:21

标签: mysql sql mariadb

我有两个数据库,我正在使用它们之间的关系。 但有些行之间没有关系。

例如:

Select user.name as name, account.code as code
from user u
JOIN account acc ON u.account_id = acc.id

我想在代码

中检索Null而不是null值

1 个答案:

答案 0 :(得分:0)

然后你应该执行LEFT OUTER JOIN代替INNER JOIN

Select user.name as name, account.code as code
from user u
LEFT JOIN account acc ON u.account_id = acc.id