Re: Join Statements - Mailing list pgsql-sql

From Mark Nielsen
Subject Re: Join Statements
Date
Msg-id 3C6EA55C.8040905@kepnet.net
Whole thread Raw
List pgsql-sql
select distinct TABLENAME_id from TABLENAME_backup where  NOT 
TABLENAME_id = ANY (select TABLENAME_id from TABLENAME)

Here is an example of me getting all the ids from the backup table that 
doesn't exist in the main table. This is similar to what you want.

I think I am answering your question, or close to it.
Mark

T Conti wrote:

> Howdy:
> 
> I need to put together an SQL statement that will return all of the
> rows in table A that are not in table B.  Table A and B have the same
> primary key.  For example:
> 
> select count(a.*) 
> from a  (nolock) left outer join
> b (nolock) on a.id = b.id
> where a.id != b.id
> 
> This did not work.  It returned 0 rows.  I know that this could be
> done very easily in a sub-select, but that seems inefficient.  Is
> there any way to accomplish what I mentioned above in the join
> statement or is the sub-select the way to go?
> 
> Thanks for the help,
> Tom
> 




pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: More problems with 7.2 & functions
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Function to split pg_trigger.tgargs