Received: from jupiter.hub.org (jupiter.hub.org [64.49.215.5]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1BFNJE77499 for ; Mon, 11 Feb 2002 10:23:19 -0500 (EST) (envelope-from news@jupiter.hub.org) Received: (from news@localhost) by jupiter.hub.org (8.11.6/8.11.6) id g1BFFb291448 for pgsql-sql@postgresql.org; Mon, 11 Feb 2002 09:15:37 -0600 (CST) (envelope-from news) From: tconti@hotmail.com (T Conti) X-Newsgroups: comp.databases.postgresql.sql Subject: Join Statements Date: 11 Feb 2002 07:15:37 -0800 Organization: http://groups.google.com/ Lines: 18 Message-ID: <5e0d3eda.0202110715.764ff25f@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200202/210 X-Sequence-Number: 6634 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