如何正确创建一个 sql 查询,该查询使用一个公共键连接四个表

how do I properly create an sql query that joins four tables with a common key

我有四个 table,它们有一个共同的密钥。 四个 table 中的三个是第四个(master)的小子集。 我想加入 tables 这样只有输出只包含来自主 table 的记录,这些记录位于其他第四个中的任何一个:

举个例子:

我的最终结果应该是这样的:

我的问题是我正在使用的联接只给我所有 table 共有的记录。 或只有 table 之一和主人共有的记录。

任何关于制定正确连接的帮助都很棒!

三个左联接将产生您想要的结果。例如:

select a.*, b.color, c.size, d.weight
from a
left join b on b.id = a.id
left join c on c.id = a.id
left join d on d.id = a.id
where b.id is not null or c.id is not null or d.id is not null

编辑:根据要求在上面添加了 WHERE 子句。