where 절이 아닌 outer join 절의 필터를 사용하여 테이블을 필터링하려고합니다. 내가 그렇게하려고 할 때 나는 예상치 못한 결과를 얻고있다. 마치 필터를 전혀 적용하지 않은 것처럼 전체 테이블이 반환됩니다.where 절 대신 outer join에 필터 조건을 추가 할 때의 차이점은 무엇입니까?
이 예제를 실행하면 마지막 두 쿼리에 대해 다른 결과가 나타납니다. 나는 그들이 같은 결과를 기대하지만, 사실이 아니다. 여기서 무슨 일이 일어나고있는거야?
declare @a table
(
id int
,content varchar(100)
)
declare @b table
(
id int
,content varchar(100)
)
insert into @a (id,content) values (1,'Apple')
insert into @a (id,content) values (2,'Banana')
insert into @a (id,content) values (3,'Orange')
insert into @b (id,content) values (1,'Juice')
insert into @b (id,content) values (2,'Peel')
insert into @b (id,content) values (3,'Julius')
--basic outer join
select * from @a a left join @b b on a.id=b.id
--outer join with where clause filter
select * from @a a left join @b b on a.id=b.id where a.id=1
--outer join with join clause filter
select * from @a a left join @b b on a.id=1 and a.id=b.id
여기 좀 보시라. http://stackoverflow.com/questions/10297231/where-clause-vs-on-when-using-join/10297312#10297312 – StuartLC