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
l@postgresql.org 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

Re: [SQL] left joins

2005-07-06 Thread Grant Morgan
aking it an inner join Hope 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 misunder

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.

[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 with multiple tables

2004-01-18 Thread Denis
n Fox" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, January 17, 2004 8:00 AM Subject: [SQL] Left joins with multiple tables > Hi, all. > > I've got a bit of a problem here. I have 4 tables - people, a, b, c (not > the original names). > > For eac

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,

[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: sel

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

[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