考虑一下:
table t1(a,b,c)
table t2(a,d,e)
table t3(r,f,g)
select t1.a,t1.b,t1.c,t2.d,t2.e
from t1 join t2
on (t1.a=t2.a)
还需要根据t1.a和t3.r选择t3表中不在上述查询结果中的记录
答案 0 :(得分:0)
如果t1.a
和t3.r
之间存在关联,那么只需在表之间建立联接,例如
select t1.a,
t1.b,
t1.c,
t2.d,
t2.e,
t3.g
from t1
join t2 on t1.a = t2.a
join t3 on t1.a = t3.r;
答案 1 :(得分:0)
如果t1.a
和t3.r
之间没有关系,那么:
SELECT t1,*, t2.*, t3.*
FROM t1
JOIN t2 ON t1.a = t2.a
JOIN t3 ON 1=1
答案 2 :(得分:0)
在NOT IN
子句中尝试WHERE
,方法如下:
SELECT
t3.*
FROM
t3 AS t3
WHERE
t3.r NOT IN
(select t1.a
from t1 join t2
on (t1.a=t2.a))