Re: Quetions on Joins - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Quetions on Joins
Date
Msg-id 20030831111037.K94333-100000@megazone.bigpanda.com
Whole thread Raw
In response to Quetions on Joins  (Alex <alex@meerkatsoft.com>)
List pgsql-general
On Mon, 1 Sep 2003, Alex wrote:

> Hi,
>
> I have a query where I want to filter out records from table_a if a
> field in table_a matches in table table_b. Basically table_b defines the
> filter.

Well something like one of the following should work depending
on how you want to treat nulls and such (and performance varies in
postgresql by version for each of the options):

 SELECT a.value_one FROM table_a AS A where NOT EXISTS
  (select 1 from table_b AS B WHERE A.value_two=B.value_two);
 SELECT a.value_one FROM table_a AS A where A.value_two NOT IN
  (select value_two from table_b);
 SELECT a.value_one FROM table_a AS A LEFT OUTER JOIN
  table_b AS B ON (a.value_two=B.value_two) WHERE B.value_two IS NULL;


pgsql-general by date:

Previous
From: Sander Smeenk
Date:
Subject: Re: PostgreSQL upgrade -> fails to start server
Next
From: Stephan Szabo
Date:
Subject: Re: SELECT Question