|
------------------------------- table sample-------------------- DINGJUN123>drop table a; 表已删除。 DINGJUN123>drop table b; 表已删除。 DINGJUN123>drop table c; 表已删除。 DINGJUN123>create table a as 2 select level id,'x'||level name 3 from dual connect by level<5 4 union all 5 select level,'y'||level 6 from dual connect by level<5; 表已创建。 DINGJUN123>create table b as 2 select level id,'x'||level name 3 from dual connect by level<3; 表已创建。 DINGJUN123>create table c as 2 select level id,'y'||level name 3 from dual connect by level<3; 表已创建。 DINGJUN123>select * from a; ID NAME ---------- -------------------- 1 x1 2 x2 3 x3 4 x4 1 y1 2 y2 3 y3 4 y4 已选择8行。 DINGJUN123>select * from b; ID NAME ---------- -------------------- 1 x1 2 x2 已选择2行。 DINGJUN123>select * from c; ID NAME ---------- -------------------- 1 y1 2 y2 已选择2行。 DINGJUN123>set null null ------------------------------test1: outer-join use old syntax-------------------------- DINGJUN123>select * 2 from a,b 3 where a.id = b.id(+) and a.name like 'x%'; ID NAME ID NAME ---------- -------------------- ---------- -------------------- 1 x1 1 x1 2 x2 2 x2 3 x3 null null 4 x4 null null 已选择4行。 -------------------------------test2: outer-join use new syntax-------------------------- --NO.1: only use 'on' clause,not 'where' clause DINGJUN123>select * 2 from a left join b 3 on a.id =b.id and a.name like 'x%'; ID NAME ID NAME ---------- -------------------- ---------- -------------------- 1 x1 1 x1 2 x2 2 x2 3 x3 null null 4 x4 null null 1 y1 null null 2 y2 null null 3 y3 null null 4 y4 null null 已选择8行。 --NO.2:use 'on' and 'where' clause DINGJUN123>select * 2 from a left join b 3 on a.id =b.id 4 where a.name like 'x%'; ID NAME ID NAME ---------- -------------------- ---------- -------------------- 1 x1 1 x1 2 x2 2 x2 4 x4 null null 3 x3 null null 已选择4行。 DINGJUN123>select * 2 from a left join b 3 on a.name like 'x%' 4 where a.id=b.id; ID NAME ID NAME ---------- -------------------- ---------- -------------------- 1 x1 1 x1 2 x2 2 x2 已选择2行。 --Questions: what can you conclude from these analytics? --something else? please wait....... |
结论和更多分析内容下步分解,对此内容感兴趣的可以先研究研究(欢迎回复参与讨论),可能刚开始看的时候迷惑不解,但是当谜底揭开,其实会得出一个很简单却很重要的结论(此结论放之四海而皆准,是学习知识之重要基石)。