语句:select T1.*,T2.* FROM T1 , T2 WHERE T1.ac=T2.ac
and t1.bb='A001'
and t2.cc='B002'
像这样的一条语句,oracle内部执行的时候是先对t1、T2连接操作,得出临时表后分别对t1 bb列,t2 cc列过滤得到最后的集合
还是 先分别对T1 bb列,T2.cc列过滤后分别得到t1',t2'集合,然后再执行连接呢?
本帖最后由 zst007007 于 2016-12-16 17:06 编辑
SQL> set linesize 1000
SQL> select t1.*,t2.* from tbl t1,tbc t2 where t1.a=t2.a and t1.a='100';
A
B
A
C
---------- -------------------- ---------- ------------------------------
10000000
100abcde
10000001
100abcde
10000002
100abcde
先过滤,后连接
1.JOIN表连接执行会比较 两个表的每一行数据(当连接的条件值为TRUE返回))
Most join queries contain at least one join condition, either in the FROM clause or in the WHERE clause;
To execute a join, Oracle Database combines pairs of rows, each containing one row from each table, for which the join condition evaluates to TRUE.
2.WHERE子句会限制连接查询的结果集 返回;
A WHERE clause that contains a join condition can also contain other conditions that refer to columns of only one table. These conditions can further restrict the rows returned by the join query