--Samples for time of join wheather can we write condition at where or ON
create table #emp(id int ,teamid int)
create table #team(tid int,name char(2))
insert into #emp values(1,1)
insert into #emp values(2,1)
insert into #emp values(3,2)
insert into #emp values(4,0)
insert into #team values(1,'A')
insert into #team values(2,'B')
insert into #team values(3,'C')
--select * from #emp
--select * from #team
--on inner join => there is no difference in Query Exc. Plan
--select * from #emp e join #team t on e.teamid=t.tid where e.teamid=2
--select * from #emp e join #team t on e.teamid=t.tid and e.teamid=2
/*on outetr join see the differnence If dealing with an OUTER JOIN (IE: LEFT, RIGHT),
there is a huge difference between the two versions because the WHERE criteria is applied after the JOIN is made.
If the criteria is specified in the ON clause, the criteria is applied before the JOIN is made which can made a considerable difference
between the result sets.*/
select * from #emp e left join #team t on e.teamid=t.tid
select * from #emp e left join #team t on e.teamid=t.tid where e.teamid=2
select * from #emp e left join #team t on e.teamid=t.tid and (e.teamid=2 or t.tid=1) and t.name='A'
drop table #emp
drop table #team
私はそれが参加し続け、より複雑なクエリのために仮定し、このクエリ – AJM