从表a中选择记录不在表b和表c中的地方

时间:2013-03-18 17:23:40

标签: sql

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

中的位置

我试过像这样的somtihing

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

由于

5 个答案:

答案 0 :(得分:1)

b.indexc.index是相应表格中的列。

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

答案 1 :(得分:0)

SELECT a.* 
FROM a 
WHERE a.`index` NOT IN (SELECT `index` FROM b) 
AND a.`index` NOT IN (SELECT `index` FROM c);

答案 2 :(得分: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)

答案 3 :(得分:0)

我假设您的查询为您提供了所有记录。您现在需要做的就是添加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

答案 4 :(得分:0)

尝试使用异常连接:

SELECT A.* FROM TABLE A
    LEFT EXCEPTION JOIN B ON B.INDEX=A.INDEX
    LEFT EXCEPTION JOIN C ON C.INDEX=A.INDEX