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] Prepare plan in plpgsql

2005-07-06 Thread Tom Lane
Jocelyn Turcotte <[EMAIL PROTECTED]> writes: > i'm wondering if there is a way to prepare and execute a plan in a > plpgsql function. You do not need that because plpgsql automatically caches plans for SQL statements appearing in a plpgsql function. regards, tom lane

[SQL] Prepare plan in plpgsql

2005-07-06 Thread Jocelyn Turcotte
Hi, i'm wondering if there is a way to prepare and execute a plan in a plpgsql function. The prepare seems to work as expected but obviously the execute plan_name(...) statement is interpreted as the plpgsql execute keyword and says me that the plan_name function don't exists is there a way to us

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.

[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