Re: Slightly OT: outer joins

From: Fran Fabrizio <ffabrizio(at)mmrd(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slightly OT: outer joins
Date: 2001-11-20 21:00:49
Message-ID: 3BFAC481.B693083@mmrd.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks everyone for the replies and instruction.

I agree that there are better ways to layout the tables, but I'm sort of the guy
who gets handed the crappy poker hand while it's owner goes to the restroom and
is expected to make it a winner. :-) In other words, I really can't lay out the
tables the way I would've wanted to.

So, within those contraints Randal hit it right on the nose. I was definitely
not catching on enough to see that the 'NATURAL' option to the joins is an
obvious choice, which was part/all of my problem. Thanks Randal and everyone!

-Fran

"Randal L. Schwartz" wrote:

> Got it on the first try:
>
> test=# select * from people natural left join color natural left join food;
> id | fname | lname | color | favorite_food
> ----+-------+--------+-------+---------------
> 1 | bob | smith | red |
> 2 | tom | jones | | eggrolls
> 3 | jane | doe | blue | ice cream
> 4 | mike | porter | |
> (4 rows)
>
> That's presuming "id" matches "id" in each table, thus the easy
> use of the "natural" keyword. The "left join" is what gives you
> nulls on the right.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brent R. Matzelle 2001-11-20 21:19:38 Re: A newbie's opinion - postgres NEEDS a Windows binary!
Previous Message JStanczak 2001-11-20 20:46:56 Solaris 8 ./confgure problem.