0

从表 a 中选择,其中记录不在表 b 和表 c 中

我试过像这样

    select a.* from table a
left outer join b on b.index=a.index
left outer join c on c.index=a.index

谢谢

4

5 回答 5

1

Whereb.indexc.indexare 各个表中的列。

select a.* from table a
    left outer join b on b.index=a.index
    left outer join c on c.index=a.index
WHERE b.index IS NULL
AND c.index IS NULL
于 2013-03-18T17:27:08.210 回答
0

尝试

SELECT a.* 
FROM a 
WHERE a.`index` NOT IN (SELECT `index` FROM b) 
AND a.`index` NOT IN (SELECT `index` FROM c);
于 2013-03-18T17:26:48.800 回答
0

尝试

select * 
from table_a a 
where a.index not in (select b.index from table_b b) 
and a.index not in (select c.index from table_c c)
于 2013-03-18T17:27:04.400 回答
0

我假设您的查询为您提供了 a 中的所有记录。您现在需要做的就是添加一个where子句:

select a.* from table a
left outer join b on b.index=a.index
left outer join c on c.index=a.index
where b.index is null and c.index is null
于 2013-03-18T17:27:14.053 回答
0

尝试使用异常连接:

SELECT A.* FROM TABLE A
    LEFT EXCEPTION JOIN B ON B.INDEX=A.INDEX
    LEFT EXCEPTION JOIN C ON C.INDEX=A.INDEX
于 2013-03-18T17:27:19.970 回答