pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nicolas Fertig <nfertig@swissnow.ch>
To: pgsql-sql@postgresql.org
Subject: OUTER JOIN with filter
Date: Sat, 1 Mar 2003 19:53:27 +0100
Message-ID: <3e61011d$0$1220$5402220f@news.sunrise.ch> (raw)

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








view thread (7+ messages)  latest in thread

Message-ID: <3e61011d$0$1220$5402220f@news.sunrise.ch>
Permalink:  ../3e61011d$0$1220$5402220f@news.sunrise.ch/
Also on:    postgresql.org/message-id/3e61011d$0$1220$5402220f@news.sunrise.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: nfertig@swissnow.ch
  Subject: Re: OUTER JOIN with filter
  In-Reply-To: <3e61011d$0$1220$5402220f@news.sunrise.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox