in reply to Re: Re: Re: SQL JOINs vs WHERE statements
in thread SQL JOINs vs WHERE statements
I just realized that although you've requested a left outer join, what you get is the same as an inner join because all of the columns in your example match up. You need to add a person who isn't in the town table at all:SELECT pt.surname, pt.town FROM ( select people.surname, town.town from people, town where people.person_id = town.person_id (+) ) pt WHERE pt.town <> 'Washington' AND pt.town IS NOT NULL
What really surprised me was that you got Jones in the results - it seems like MS SQL Server did this:insert into people ( person_id, surname ) values ( 5, 'Drifter' )
Essentially, it pared down the town table before joining - probably good for performance, although it gives strange results. Interesting - you learn something new every day here at sqlMonks. What? This is perlMonks?SELECT people.surname, t1.town FROM ( select * from town where town <> 'Washington' AND town IS NOT NULL ) t1, people WHERE people.person_id = t1.person_id (+)
|
|---|