Re: [SQL] help on a query

2004-10-08 Thread Greg Stark
Michelle Murrain <[EMAIL PROTECTED]> writes: > The OUTER JOIN version is quite a bit more efficient (by an order of magnitude) > than the option with WHERE NOT EXISTS subquery. This is going to be heavily dependent on the version of postgres. IN/NOT IN execution has improved a lot in 7.4 and lat

Re: [SQL] help on a query

2004-10-08 Thread Michelle Murrain
Thomas F.O'Connell wrote: I think the OUTER JOIN version is probably more efficient, but EXPLAIN would tell you. Well, this all makes me feel better. For everyone's edification: select registration_id FROM registrations where registration_id not in (select registration_id from receipts); Generates

Re: [SQL] help on a query

2004-10-08 Thread Thomas F . O'Connell
Oct 2004 08:44:23 +0400 To: Thomas.F.O'[EMAIL PROTECTED], [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] From: [EMAIL PROTECTED] Sender: [EMAIL PROTECTED] 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

Re: [SQL] help on a query

2004-10-08 Thread Achilleus Mantzios
TED] > Cc: [EMAIL PROTECTED] > From: [EMAIL PROTECTED] > Sender: [EMAIL PROTECTED] > 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 >

Re: [SQL] help on a query

2004-10-08 Thread CHRIS HOOVER
EMAIL PROTECTED] 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 receipt

Re: [SQL] help on a query

2004-10-07 Thread sad
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

Re: [SQL] help on a query

2004-10-07 Thread Thomas F . O'Connell
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 ); There might be a more efficient version with JOINs that don't require a subquery, but this should get

[SQL] help on a query

2004-10-07 Thread Michelle Murrain
Hi all, This is one of those things I know I should know, but it's not coming to me. It's probably really simple. I have two related tables, registrations and receipts, related by the field registration_id. So registrations looks kinda like: registration_id bigint (primary key) foo varchar(10)