14:39:20 SQL> select * from a; COL ---------- 1 1 1 2 2 3 4 5 5 6已选择10行。已用时间: 00: 00: 00.62 14:39:38 SQL> select * from b; COL ---------- 1 2 3 4 5 6 8 8 10 100 12 COL ---------- 12已选择12行。已用时间: 00: 00: 00.78 14:39:42 SQL> select count(col) from a;COUNT(COL) ---------- 10已用时间: 00: 00: 00.32 14:39:51 SQL> select count(col) from b;COUNT(COL) ---------- 12已用时间: 00: 00: 00.16 14:39:57 SQL> select count(col) from b where col in(select col from a);COUNT(COL) ---------- 6已用时间: 00: 00: 00.15 14:40:09 SQL> select count(col) from a where col not in(select col from b);COUNT(COL) ---------- 0已用时间: 00: 00: 00.31 14:40:21 SQL> select count(col) from a where col not in( 14:40:28 2 select col from b where col in(select col from a));COUNT(COL) ---------- 0已用时间: 00: 00: 00.16 14:40:29 SQL>
TO 楼主 你把第5句的COUNT(*)换成* 看看结果是什么,其中的field1都有哪些,也许是一些奇怪的东东。
我猜如果确有24个,那24个field1应该是NULL吧。
估计是你的语句有问题。如果table1的字段1没有重复值的话,那就更不对了。
Select 子段1 From table1 Where 子段1 Not In(Select 子段1 From table2 Where 子段1 In (select 子段1 From table1));这句话的结果是什么呀,不是叫你试一下吗
Select 子段1 From table1 Where 子段1 Not In(Select 子段1 From table2 Where 子段1 In (select 子段1 From table1)); 结果是24条
----------
1
1
1
2
2
3
4
5
5
6已选择10行。已用时间: 00: 00: 00.62
14:39:38 SQL> select * from b; COL
----------
1
2
3
4
5
6
8
8
10
100
12 COL
----------
12已选择12行。已用时间: 00: 00: 00.78
14:39:42 SQL> select count(col) from a;COUNT(COL)
----------
10已用时间: 00: 00: 00.32
14:39:51 SQL> select count(col) from b;COUNT(COL)
----------
12已用时间: 00: 00: 00.16
14:39:57 SQL> select count(col) from b where col in(select col from a);COUNT(COL)
----------
6已用时间: 00: 00: 00.15
14:40:09 SQL> select count(col) from a where col not in(select col from b);COUNT(COL)
----------
0已用时间: 00: 00: 00.31
14:40:21 SQL> select count(col) from a where col not in(
14:40:28 2 select col from b where col in(select col from a));COUNT(COL)
----------
0已用时间: 00: 00: 00.16
14:40:29 SQL>
你把第5句的COUNT(*)换成* 看看结果是什么,其中的field1都有哪些,也许是一些奇怪的东东。
2 test2
3 84081041
4 37602722
5 37602723
6 37602724
……
谢谢大家。