OUTER JOIN with filter - Mailing list pgsql-sql

From Nicolas Fertig
Subject OUTER JOIN with filter
Date
Msg-id 3e61011d$0$1220$5402220f@news.sunrise.ch
Whole thread Raw
Responses Re: OUTER JOIN with filter
Re: OUTER JOIN with filter
List pgsql-sql
Hello,

Can anyone help me with the problem bellow ?

I want to have all the row in table "table_main" with the value in the table
"table_slave" (value or null if not exist)

It is possible to have the same result without sub-select in OUTER JOIN
(speed problem on big table) ?

Actualy this is what I make...

CREATE TABLE "table_main" (  "id" int4,  "some_field" varchar(100)
);

CREATE TABLE "table_slave" (  "id" int4,  "name" varchar(100),  "c1" varchar(30)
);

SELECT TM.some_field, TS.name
FROM table_main TM
LEFT OUTER JOIN (SELECT name FROM table_slave WHERE c1 = 'myvalue') TS
USING(id)


the request bellow is not correct:

SELECT TM.some_filed, TS.name
FROM table_main TM
LEFT OUTER JOIN table_slave TS USING(id)
WHERE (TS.c1 = 'myc1' OR TS.c1 IS NULL)

Many thanks,

Nicolas







pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Beginner needs help
Next
From: Denis Zaitsev
Date:
Subject: Re: Are scalar type's in/out functions implicitly STRICT?