一个简单的SQL问题(关于oracle的select 语句) 你这样查不到你想要的结果.那样会导致查询到很多很多的记录!建议改成select * from awhere a.name not in (select b.name from bwhere b.name is not null) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from a where not exists (select * from b where a.name=b.name)也能用 不好意思,是我搞错了,没有 distinct!我的SQL: select distinct name from a where name not in(select distinct name from b);谢谢两位的帮助了! SQL> select * from a; COL1---------- 1 2 3 4 5 6 7 8 9 1010 rows selected.SQL> select * from b; COL1---------- 1 2 3 4 5SQL> select * from a where not exists (select * from b where a.col1=b.col1); COL1---------- 6 7 8 9 10不是要上面的结果??? zzwind5() 兄:连接的结果有三种情况:a表存在,b表不存在;a表存在,b表存在;a表不存在,b表存在。你的语句多了一种a表没有,b表有的情况。 楼上的看来你没有真正理解 exists 和 not exists 的用法select * from a where not exists (select * from b where a.col1=b.col1);等同于select * from a where a.col1 not in (select b.col1 from b ); windows客户端乱码问题。 怎么用SQL语句查看表空间问题 关于left join 问题,在SQLserver中执行的结果与在oracle中执行的结果不一样 新手 小心地求诸位解惑 請問pl/sql 中產生隨機數的函數是什么﹖ 如何动态汇总下级数据啊 创建自动增长ID无效 帮忙看一下 表空间的数据文件空间分配 急:如何大批量选择,更新,插入数据 oracle11奇怪的问题:连接不上远程的数据库,但本地的可以连。。 对数据库的表每一项操作,比如“delete、insert、update”,在数据库的日志里都有记录吗?我能查看这些操作吗? 一个关于在ORACLE中批量插入的问题
也能用
我的SQL: select distinct name from a where name not in(select distinct name from b);
谢谢两位的帮助了!
----------
1
2
3
4
5
6
7
8
9
1010 rows selected.SQL> select * from b; COL1
----------
1
2
3
4
5SQL> select * from a where not exists (select * from b where a.col1=b.col1); COL1
----------
6
7
8
9
10不是要上面的结果???
连接的结果有三种情况:a表存在,b表不存在;a表存在,b表存在;a表不存在,b表存在。你的语句多了一种a表没有,b表有的情况。
select * from a where not exists (select * from b where a.col1=b.col1);
等同于
select * from a where a.col1 not in (select b.col1 from b );