From: | "Medi Montaseri" <montaseri(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Query question |
Date: | 2008-05-22 21:28:43 |
Message-ID: | 8078a1730805221428p6c261893r6fc95ca920299370@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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_id integer not null , t2_id integer );
Now I'd like to show a list of records from T1_T2 but reference T1 and T2
for the names instead of IDs. But T1_T2.t2_id might be null
select T1_T2.id, T1.name , T2.name from T1, T2, T1_T2
where T1_T2.t1_id = T1.id and T1_T2.t2_id = T2.id
Basically since t2_id might be null, the condition will fail and the query
will fail
thanks
Medi
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2008-05-22 21:50:16 | Re: Query question |
Previous Message | Sebastian Rychter | 2008-05-22 18:29:23 | Extremely Low performance with ODBC |