select a.* from a, ( select id from a minus select id from b ) b where a.id=b.id
A表中不在B表的数据 以ID关联,求一个效率高的SQL,最好能不用子查询,请高手们帮忙,多谢了!! 在A不在B,A多B少 这个问题出现的比较多,可以利用外连接来做的,如果a,b字段关联后,B表有其他字段至少一个不为null假设a.m=b.m ,b.n 不为空 select a.* from a,b where a.m=b.m(+) and b.n is null
楼上的正解!呵呵. select a.* from a,b where a.id=b.id(+) and b.id is null
SELECT i FROM a WHERE NOT EXISTS ( SELECT 0 FROM b WHERE a.id = b.id )这样不知可否?效率如何?
from a,
(
select id
from a
minus
select id
from b
) b
where a.id=b.id
在A不在B,A多B少
这个问题出现的比较多,可以利用外连接来做的,如果a,b字段关联后,B表有其他字段至少一个不为null假设a.m=b.m ,b.n 不为空
select a.* from a,b
where a.m=b.m(+) and b.n is null
select a.*
from a,b
where a.id=b.id(+)
and b.id is null
SELECT i
FROM a
WHERE NOT EXISTS
(
SELECT 0
FROM b
WHERE a.id = b.id
)这样不知可否?效率如何?