left join ,innerJoin

declare @t1 table ( id int ,  val varchar(20))  

insert into @t1
 select 1 , 'a'
union select 2 , 'b'  
union select 3 , 'd' ;

declare @t2 table ( id int ,  val varchar(20))  

insert into @t2
select 2 , 'b'  
union select 3 , 'b'   
union select 4 , 'c'  ;

 
 select * from @t1 ;
 select * from @t2 ;

select *
from @t1 t1
left join @t2 t2 on ( t1.val = t2.val)

LeftJoin 扫描两个结果集,对外表来说是 左行数 个表扫描。

posted @ 2011-10-24 18:32  NewSea  阅读(250)  评论(0编辑  收藏  举报