问一个sql语句问题 表结构是这样a b2 13 24 36 5如果b中的在a中存在就把b滤掉,最后应该就剩下 2 1,6 5。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a,b from table where b not in (select a from table) 原来是列比较啊:select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b ) SELECT * FROM TABLE A WHERE NOT EXISTS( select 1 from TABLE where a=A.b ) select * from tab where a not in (select b from tab) select * from tab where a not in (select b from tab) 经过测试,结果完全正确:select test.a, test.b from testtable test where test.b not in ( select t1.a from testtable t1) 支持使用exists,效率比较高:select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b ) 单个表的查询可以用自连接self join,把一个表当成两个表来看 exists比較快一點,樓上正解select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b ) select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b ) select * from tab where a not in (select b from tab) oracle 怎么修改主键类型 数据字典和动态性能视图 JOB调用存储过程的怪问题,求高手解答 怎么样导出储存过程 Oracle的视频资料 Oracle如何禁止客户端以SYS用户登录 ora-00903错误 表名无效?? 请问怎样从oracle导出表数据? 求一sql语句! 关于创建存储过程或触发器的问题??? 关于左连接的问题 关于RECORD记录类型
原来是列比较啊:
select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b )
SELECT * FROM TABLE A WHERE NOT EXISTS( select 1 from TABLE where a=A.b )
select test.a, test.b from testtable test
where test.b not in (
select t1.a from testtable t1
)
select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b )
select a,b from tb t1 where not exists(select 1 from tb t2 where t2.a=t1.b )