Re: help on a query

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: CHRIS HOOVER <CHRIS(dot)HOOVER(at)companiongroup(dot)com>
Cc: sad(at)bankir(dot)ru, "Thomas F O'Connell" <tfo(at)sitening(dot)com>, <pgsql-sql(at)postgresql(dot)org>, <mmurrain(at)dbdes(dot)com>
Subject: Re: help on a query
Date: 2004-10-08 13:03:34
Message-ID: Pine.LNX.4.44.0410081559340.12604-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

O CHRIS HOOVER έγραψε στις Oct 8, 2004 :

> Just curious, what is wrong with the first way of coding the solution?
> ------------------( Forwarded letter 1 follows )---------------------
> Date: Fri, 8 Oct 2004 08:44:23 +0400
> To: Thomas.F.O'Connell[tfo](at)sitening(dot)com(dot)comp, mmurrain(at)dbdes(dot)com(dot)comp
> Cc: pgsql-sql(at)postgresql(dot)org(dot)comp
> From: sad(at)bankir(dot)ru(dot)comp
> Sender: pgsql-sql-owner+m19150(at)postgresql(dot)org(dot)comp
> Subject: Re: [SQL] help on a query
>
> On Friday 08 October 2004 07:10, Thomas F.O'Connell wrote:
> > A query that should get the job done is:
> >
> > SELECT registration_id
> > FROM registrations r
> > WHERE NOT EXISTS (
> > SELECT 1
> > FROM receipts
> > WHERE registration_id = r.registration_id
> > );
>
> Don't, PLEASE, don't !!!
>
> drive this way :
>
> SELECT r.registration_id
> FROM registrations AS r
> LEFT OUTER JOIN receipts AS rec
> ON rec.registration_id = r.registration_id
> WHERE rec.registration_id IS NULL;

Some one could add the same dont please dont, and advise:

select registration_id FROM registrations
where registration_id not in (select registration_id from receipts);

but its actually version/data dependent i suppose.

>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
-Achilleus

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas F.O'Connell 2004-10-08 15:06:57 Re: help on a query
Previous Message CHRIS HOOVER 2004-10-08 13:02:00 Re: help on a query