pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Seb <spluque@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: self join
Date: Sat, 14 May 2011 17:49:15 -0500
Message-ID: <87tycwsxsk.fsf@kolob.subpolar.dyndns.org> (raw)
References: <87y629rl34.fsf@kolob.subpolar.dyndns.org>
	<BANLkTinOMHW_j0e6-6BHr4BOGLZKwEEZDA@mail.gmail.com>

On Sun, 15 May 2011 07:39:06 +0900,
Ian Lawrence Barwick <barwick@gmail.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




view thread (15+ messages)  latest in thread

Message-ID: <87tycwsxsk.fsf@kolob.subpolar.dyndns.org>
Permalink:  ../87tycwsxsk.fsf@kolob.subpolar.dyndns.org/
Also on:    postgresql.org/message-id/87tycwsxsk.fsf@kolob.subpolar.dyndns.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spluque@gmail.com
  Subject: Re: self join
  In-Reply-To: <87tycwsxsk.fsf@kolob.subpolar.dyndns.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox