Question on a select

From: Madison Kelly <linux(at)alteeve(dot)com>
To: PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Question on a select
Date: 2005-01-02 03:32:17
Message-ID: 41D76B41.1030607@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Hikida 2005-01-02 04:18:23 Re: Question on a select
Previous Message Jeff Davis 2005-01-02 02:35:30 Re: disabling OIDs?