[英]SQL : Join of inner join
我会使用exists
:
select . . .
from a
where exists (select 1 from b where b.? = a.?) or
exists (select 1 from c where b.? = a.?);
如果您想要所有表中的列,请使用left join
并使用where
子句:
select . . .
from a left join
b
on . . . left join
c
on . . .
where c.? is not null or b.? is not null;
我终于找到了怎么做……而且非常简单快捷:
SELECT ... FROM A
INNER JOIN B ON ....
UNION
SELECT ... FROM A
INNER JOIN C ON ....
你说对了。 顺便说一句,我认为你的图片不正确。 如果您要查找属于 A 的一部分和属于 B“OR”C 的一部分的记录,则圆 B 和 C 应该没有交集。 您改为绘制属于 A 的一部分和 B “AND” C 的一部分的记录。 如果绘制正确,您会清楚地看到最终的并集结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.