有一个像id-name-roll这样的表 我有一些常量给定值的卷像 - (1,2,6,8,5)让它成为A. 表有滚动像(1,2,3,4,5,6,7)让它设置为B. 我想知道A-B 表示滚动值不在表中但存在于给定常量集A
中的值 我试过了 从" tablename"中选择滚动哪里不滚(1,2,6,8,5); 但它恰好相反 - 它返回B-A 但我想要A-B 请帮忙 我也试过了从tablename中选择(1,2,6,8,5)来自双减去选择滚动; 但它给出了一些syntex错误
答案 0 :(得分:0)
这是你想要的吗?
select a.*
from (select 1 as id from dual union all
select 2 as id from dual union all
select 6 as id from dual union all
select 8 as id from dual union all
select 5 as id from dual
) a
where not exists (select 1 from b where a.id = b.id);
答案 1 :(得分:0)
(select 1 as id from dual
union all
select 2 from dual
union all
select 6 from dual
union all
select 8 from dual
union all
select 5 from dual
)
minus
Select id from b