Question on a select - Mailing list pgsql-general

From Madison Kelly
Subject Question on a select
Date
Msg-id 41D76B41.1030607@alteeve.com
Whole thread Raw
Responses Re: Question on a select
List pgsql-general
Hi all,

   This is my first post here so please let me know if I miss any list
guidelines. :)

   I was hoping to get some help, advice or pointers to an answer for a
somewhat odd (to me at least) SELECT. What I am trying to do is select
that values from one table where matching values do not exist in another
table.

For example:

   Let's say 'table_a' has the columns 'a_name, a_type, a_dir,
a_<others>' and 'table_b' has the columns 'b_name, b_type, b_dir,
b_<others>' where 'others' are columns unique to each table. What I need
to do is select all the values in 'a_name, a_type, a_dir' from 'table_a'
where there is no matching entries in "table_b's" 'b_name, b_type, b_dir'.

   I know I could do something like:

SELECT a_name, a_type, a_dir FROM table_a;

   and then loop through all the returned values and for each do a
matching select from 'table_b' and use my program to catch the ones not
in 'table_b'. This is not very efficient though and I will be searching
through tables that could have several hundred thousand entries so the
inefficiency would be amplified. Is there some way to use a join or
something similar to do this?

   Thank you all!

Madison

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: disabling OIDs?
Next
From: "Vincent Hikida"
Date:
Subject: Re: Question on a select