Re: [SQL] left joins

2005-07-06 Thread Tony Wasson
On 7/6/05, Ragnar Hafstaư <[EMAIL PROTECTED]> wrote: > On Wed, 2005-07-06 at 11:33 +0100, Nick Stone wrote: > > I've had exactly yhe same problem - try changing the query to. > > > > select count(*) > > from h left join p using (r,pos) and p.r_order=1 > > where h.tn > 20 > > and h.tn < 30 > > re

Re: [SQL] left joins

2005-07-06 Thread Ragnar Hafstaư
On Wed, 2005-07-06 at 11:33 +0100, Nick Stone wrote: > I've had exactly yhe same problem - try changing the query to. > > select count(*) > from h left join p using (r,pos) and p.r_order=1 > where h.tn > 20 > and h.tn < 30 really ? is this legal SQL ? is this a 8.0 feature ? I get syntax error

Re: [SQL] left joins

2005-07-06 Thread Tom Lane
"Grant Morgan" <[EMAIL PROTECTED]> writes: > select count(*) > from h left join p using (r,pos) > where h.tn > 20 > and h.tn < 30 > and p.r_order=1 > since it is a left join I though I should get a number no smaller in > the left join than the original unjoined query. It seems to be acting > lik

Re: [SQL] left joins

2005-07-06 Thread Nick Stone
I've had exactly yhe same problem - try changing the query to. select count(*) from h left join p using (r,pos) and p.r_order=1 where h.tn > 20 and h.tn < 30 I think that should do it - the syntax you used would work in Oracle and MS SQL but there's a subtle difference with the way Postgres wor

Re: [SQL] left joins

2005-07-06 Thread Grant Morgan
Thank you Richard and Nick, your right. And what Nick showed below is what I wanted. Cheers, Grant On Wed, 06 Jul 2005 19:33:03 +0900, Nick Stone <[EMAIL PROTECTED]> wrote: I've had exactly yhe same problem - try changing the query to. select count(*) from h left join p using (r,pos) and p

Re: [SQL] left joins

2005-07-06 Thread Richard Huxton
Grant Morgan wrote: I am having a problem with left joins in Postgresql.(probably my misunderstanding of left joins) My first Query returns 70,000 select count(*) from h where h.tn > 20 and h.tn < 30 my left join returns only 34,000 select count(*) from h left join p using (r,pos) where h.

Re: [SQL] Left joins with multiple tables

2004-01-18 Thread Denis
Hi Colin, Try select id, name, a.field1, b.field2, c.field3 from people p left outer join a on (a.person_id = p id) left outer join b on (b.person_id = p.id) left outer join c on (c.person_id = p.id); HTH Denis - Original Message - From: "Colin Fox" <[EM

Re: [SQL] Left joins with multiple tables

2004-01-18 Thread Richard Poole
On Sat, Jan 17, 2004 at 02:30:01AM +, Colin Fox wrote: > For each person in the people table, they may or may not have a record in > a, may or may not have a record in b, and may or may not have a record in > c. ... > But I'd like to be able to do something like: > > select > id, name,

Re: [SQL] Left Joins...

2001-05-30 Thread Renato De Giovanni
> I've got a nasty query that joins a table onto itself like 22 times. > I'm wondering if there might be a better way to do this, and also how > I can left join every additional table on the first one. By this I > mean that if f1 matches my criteria and therefore isn't null, then > every other joi