[SQL] left joins

2005-07-06 Thread Grant Morgan
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.tn 20 and h.tn 30

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

Re: [SQL] left joins

2005-07-06 Thread Grant Morgan
this helps Nick -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Grant Morgan Sent: 06 July 2005 11:02 To: pgsql-sql@postgresql.org Subject: [SQL] left joins I am having a problem with left joins in Postgresql.(probably my misunderstanding of left joins) My

Re: [SQL] left joins

2005-07-06 Thread Nick Stone
Subject: [SQL] left joins 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

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 like an inner

[SQL] Left joins with multiple tables

2004-01-18 Thread Colin Fox
Hi, all. I've got a bit of a problem here. I have 4 tables - people, a, b, c (not the original names). 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. Handling the first table (a) is easy:

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 joined

[SQL] Left Joins...

2001-05-27 Thread Michael Richards
I've got a select that pulls many values from the same table. Basicaly for a given formid there can be many fields each one depending on a definition. So form1 may be broken down as follows: fieldid 1 firstname 2 lasname 3 postal code Rather than sticking this data in