[英]SQL left join with conditions from two tables
Is there a way to combine the following queries Q1 and Q2 into one? 有没有一种方法可以将以下查询Q1和Q2合并为一个?
I believe it to be important to know the structure of the tables a, b & c: 我认为了解表a,b和c的结构很重要:
All b.01 values will be present in a.01. 所有b.01值都将出现在a.01中。
This is Q1: 这是第一季度:
SELECT a.ID, b.[02], b.[01]
FROM a, b
WHERE (((b.[01])=[a].[01]));
This is Q2: 这是第二季度:
SELECT Q1.*
FROM Q1 LEFT JOIN c ON [Q1].[ID]=[c].[01]
WHERE ((c.[02]) Is Null);
Something like this might work: 这样的事情可能会起作用:
SELECT a.ID, b.[02], b.[01]
FROM a INNER JOIN b ON b.[01] = a.[01]
LEFT JOIN c ON a.id = c.[01]
WHERE c.[02] IS NULL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.