Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 condition in join expression or in where clause?

Author  Topic 

heze
Posting Yak Master

192 Posts

Posted - 2007-02-16 : 15:51:08
hi does anybody know the difference between:

select * from mytab1 m
left join myTab2 m2 on m2.cond=1 and m2.id=m.id

--and

select * from mytab1 m
left join myTab2 m2 on and m2.id=m.id
where m2.cond=1

--Tnank you

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-16 : 16:02:00
What do the query plan tell you?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-16 : 16:04:49
[code]declare @t1 table (id int)

insert @t1
select 1 union all
select 2

declare @t2 table (id int, cond int)

insert @t2
select 1, 1 union all
select 1, 5 union all
select 3, 1

select * from @t1 m
left join @t2 m2 on m2.cond=1 and m2.id=m.id

select * from @t1 m
left join @t2 m2 on m2.id=m.id
where m2.cond=1[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -