Re: [SQL] Extremely Low performance with ODBC

2008-05-22 Thread Steve Crawford
Sebastian Rychter wrote: Hi, I'm executing a query through psql ODBC which is taking around 2 minutes to complete. When I run it from PgAdmin it takes less than 3 seconds. The query itself has : . 15 inner joins (from just around 10 different tables -- the other inner joins are using diffe

Re: [SQL] Substract queries

2008-05-22 Thread Ramasubramanian G
Hi , The query is like this , Except SELECT * from ((SELECT COUNT(id) FROM table1) Except (SELECT COUNT(id) FROM table2))tmp Regards, Ram -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig Ringer Sent: Thursday, May 22, 2008 9:05 PM To: Nacef LA

Re: [SQL] Query question

2008-05-22 Thread Medi Montaseri
Thanks Stephan, My real DDL include a forign key reference to T2.id and since I am ok with NULL value then the "left outer join" indeed have solved the problem. Thanks again Medi On Thu, May 22, 2008 at 2:50 PM, Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Thu, 22 May 2008, Medi Montaseri wrot

Re: [SQL] Query question

2008-05-22 Thread Stephan Szabo
On Thu, 22 May 2008, Medi Montaseri wrote: > Hi, > I can use some help with the following query please. > > Given a couple of tables I want to do a JOIN like operation. Except that one > of the columns might be null. > > create table T1 ( id serial, name varchar(20) ); > create table T2 ( id seria

[SQL] Query question

2008-05-22 Thread Medi Montaseri
Hi, I can use some help with the following query please. Given a couple of tables I want to do a JOIN like operation. Except that one of the columns might be null. create table T1 ( id serial, name varchar(20) ); create table T2 ( id serial, name varchar(20) ); create table T1_T2 ( id serial, t1_

[SQL] Extremely Low performance with ODBC

2008-05-22 Thread Sebastian Rychter
Hi, I'm executing a query through psql ODBC which is taking around 2 minutes to complete. When I run it from PgAdmin it takes less than 3 seconds. The query itself has : . 15 inner joins (from just around 10 different tables - the other inner joins are using different aliases for the same tables)

Re: [SQL] Substract queries

2008-05-22 Thread Niklas Johansson
On 22 maj 2008, at 17.15, Nacef LABIDI wrote: I was wondering how can I substract result between select queries. I mean I want to issue a query that does this : (select * from mytable where condition1) - (select * from mytable where condition2) If you (as implied above) query the same table

Re: [SQL] Substract queries

2008-05-22 Thread Nacef LABIDI
Thanks to all the EXEPT keyword is what I was looking for On Thu, May 22, 2008 at 5:36 PM, Niklas Johansson <[EMAIL PROTECTED]> wrote: > > On 22 maj 2008, at 17.15, Nacef LABIDI wrote: > >> I was wondering how can I substract result between select queries. I mean >> I want to issue a query that d

Re: [SQL] Substract queries

2008-05-22 Thread Craig Ringer
Nacef LABIDI wrote: Hi all, I was wondering how can I substract result between select queries. I mean I want to issue a query that does this : (select * from mytable where condition1) - (select * from mytable where condition2) If the subqueries return single (scalar) results, you can just subt

Re: [SQL] Substract queries

2008-05-22 Thread Robins Tharakan
Probably you are looking for EXCEPT. SELECT * FROM Tbl1 WHERE a=1 EXCEPT SELECT * FROM tbl2 WHERE a=1 and b=1; http://www.postgresql.org/docs/8.3/interactive/sql-select.html Regards, *Robins Tharakan* -- Forwarded message -- From: Nacef LABIDI <[EMAIL PROTECTED]> Date: Thu, May

[SQL] Substract queries

2008-05-22 Thread Nacef LABIDI
Hi all, I was wondering how can I substract result between select queries. I mean I want to issue a query that does this : (select * from mytable where condition1) - (select * from mytable where condition2) Thanks to all Nacef