I figured you knew about naming columns when inserting, I just wanted it in the record for any SQL newbies out there.

I guess to be completely clear and sure of your results, you'd have to do the following to be equivalent to the left outer join version (in MS SQL Server at least):
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
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:
insert into people ( person_id, surname ) values ( 5, 'Drifter' )
What really surprised me was that you got Jones in the results - it seems like MS SQL Server did this:
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 (+)
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?
Update
That part about it not being an inner join instead of a left outer join? Forget about it - it is a left outer join because of MS SQL Server's apparent order of operations (see my last SQL snippet above).

In reply to Re: Re: Re: Re: SQL JOINs vs WHERE statements by bean
in thread SQL JOINs vs WHERE statements by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.