表A:a1,a2,a3,a4...
表B:b1,b2,b3,b4...select count(*) from A a, B b where a.a1 = '20090902' and a.a2 = b.b1;select count(*) from A where a1 = '20090902' and a2 in(select b1 from B);执行的时候查询出的值是不一样,请问一下这2个sql语句的区别,谢谢。
表B:b1,b2,b3,b4...select count(*) from A a, B b where a.a1 = '20090902' and a.a2 = b.b1;select count(*) from A where a1 = '20090902' and a2 in(select b1 from B);执行的时候查询出的值是不一样,请问一下这2个sql语句的区别,谢谢。
解决方案 »
- 求解决 ora-02778 name giver for the log directory is invaild
- 多表关联查询的连接条件问题
- Oracle Service Bus的For Each用法
- ORACLE安装后的配置问题
- 如何判断打开了那些游标?
- 调试的第一个包例子,帮我看看这个包问题出在什么地方呀?谢谢
- 在线等待 sql高手 解决难题
- 本人去年一时糊涂,买了好多自己不要的书,出卖中。。(版主不要删除呀!呀!呀!)
- JAVA中的CHAR和ORACLE中的数据类型对应问题
- 各位高人帮忙---关于oracle数据库导到db2数据库解决方法(表结构和数据都导过去)
- oracle游标问题,连续两条记录比较
- Oracle 数据导出问题
因为在连接结果中,a中的一条记录可能出现多次
第二句中的count(*)改成*
对比一下结果
楼主可以用下面代码来统计
select count(1) from A where
exists(select 1 from b where b1=a.a2)
and a1 = '20090902' ;