Re: [GENERAL] How would I write this query...

2006-05-02 Thread John D. Burger
Martijn van Oosterhout wrote: That's because they're not equivalent. IN/NOT IN have special semantics w.r.t. NULLs that make them a bit more difficult to optimise. OUTER JOINs on the other hand is easier since in a join condition anything = NULL evaluates to NULL -> FALSE. Which is why Hash IN

Re: [GENERAL] How would I write this query...

2006-05-02 Thread Martijn van Oosterhout
On Mon, May 01, 2006 at 05:23:41PM -0400, John D. Burger wrote: > In my experience, queries like the OUTER LEFT JOIN version posted > earlier are usually much more efficient than NOT IN queries like the > above. The planner seems to be pretty smart about turning (positive) > IN queries into joi

Re: [GENERAL] How would I write this query...

2006-05-02 Thread Alban Hertroys
Guy Rouillier wrote: Jim Fitzgerald wrote: Hi - I have two tables, one of them has names of people and an associated integer ID. The other table is a list of the people (from the first table) by their ID number that have signed up for a class. How would I write a query that would list all t

Re: [GENERAL] How would I write this query...

2006-05-01 Thread Guy Rouillier
John D. Burger wrote: >> select * >> from people >> where id not in >> ( >> select id >> from class_registration >> ) > > In my experience, queries like the OUTER LEFT JOIN version posted > earlier are usually much more efficient than NOT IN queries like the > above. The planner seems to be prett

Re: [GENERAL] How would I write this query...

2006-05-01 Thread John D. Burger
select * from people where id not in ( select id from class_registration ) In my experience, queries like the OUTER LEFT JOIN version posted earlier are usually much more efficient than NOT IN queries like the above. The planner seems to be pretty smart about turning (positive) IN queries in

Re: [GENERAL] How would I write this query...

2006-05-01 Thread Guy Rouillier
Jim Fitzgerald wrote: > Hi - > > I have two tables, one of them has names of people and an associated > integer ID. The other table is a list of the people (from the first > table) by their ID number that have signed up for a class. How would > I write a query that would list all the people fr

Re: [GENERAL] How would I write this query...

2006-05-01 Thread Ragnar
On sun, 2006-04-30 at 11:32 -0700, Jim Fitzgerald wrote: > I have two tables, one of them has names of people and an associated > integer ID. The other table is a list of the people (from the first table) > by their ID number that have signed up for a class. How would I write a > query that

Re: [GENERAL] How would I write this query...

2006-05-01 Thread Michael Glaesemann
On May 1, 2006, at 3:32 , Jim Fitzgerald wrote: I have two tables, one of them has names of people and an associated integer ID. The other table is a list of the people (from the first table) by their ID number that have signed up for a class. How would I write a query that would list a

[GENERAL] How would I write this query...

2006-05-01 Thread Jim Fitzgerald
Hi - I have two tables, one of them has names of people and an associated integer ID. The other table is a list of the people (from the first table) by their ID number that have signed up for a class. How would I write a query that would list all the people from the first table that do not