Re: self join

From: Seb <spluque(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: self join
Date: 2011-05-14 22:49:15
Message-ID: 87tycwsxsk.fsf@kolob.subpolar.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, 15 May 2011 07:39:06 +0900,
Ian Lawrence Barwick <barwick(at)gmail(dot)com> wrote:

[...]

> Your query doesn't have an explicit join and is producing a cartesian
> result.

> I don't think a self- join will work here; a subquery should produce
> the result you're after:

> SELECT * FROM tmp t1 WHERE NOT EXISTS(SELECT TRUE FROM tmp t2 WHERE
> t2.b=t1.a);

This produces exactly the result I'm after. I'll need to understand the
EXISTS statement there in more detail.

Thanks!

--
Seb

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jasen Betts 2011-05-15 02:36:46 Re: self join
Previous Message Ian Lawrence Barwick 2011-05-14 22:39:06 Re: self join