Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Having a me...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 3423 of 3799
Post > Topic >>

Re: Having a mental block with (self) outer joins

by depesz@[EMAIL PROTECTED] (hubert depesz lubaczewski) Apr 21, 2008 at 04:05 PM

On Mon, Apr 21, 2008 at 03:48:23PM +0200, Thomas Kellerer wrote:
> name, id, parent_id
> ROOT, 1, NULL
> CHILD1, 2, 1
> CHILD2, 3, 1
> 
> I would have expected the following result:
> 
> ROOT, NULL
> ROOT, CHILD1
> ROOT, CHILD2
> 
> but the row with (ROOT,NULL) is not returned. 

why would you expect it?
the columns are: parent and child (on your output).
you dont have any row that has *parent_id = 1* and id = NULL.

you can get this output though:

NULL, ROOT
ROOT, CHILD1
ROOT, CHILD2

with this query:

select p.name as parent, c.name as child from category c left outer join
category p on c.parent_id = p.id

depesz

-- 
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA.  here's my CV!" :)
http://www.depesz.com/
- blog dla ciebie (i moje CV)

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 4 Posts in Topic:
Having a mental block with (self) outer joins
spam_eater@[EMAIL PROTECT  2008-04-21 15:48:23 
Re: Having a mental block with (self) outer joins
depesz@[EMAIL PROTECTED]   2008-04-21 16:05:21 
Re: Having a mental block with (self) outer joins
spam_eater@[EMAIL PROTECT  2008-04-21 16:15:20 
Re: Having a mental block with (self) outer joins
Dennis Muhlestein <djm  2008-04-24 16:20:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 21:39:22 CST 2008.