From: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] unmatched
Date: Thu, 10 Jun 1999 16:32:08 -0500
Message-ID: <19990610163208.A878@wallace.ece.rice.edu> (raw)
In-Reply-To: <Pine.BSI.3.91.990610200217.15423B-100000@access1.lan2wan.com>
References: <Pine.BSI.3.91.990610200217.15423B-100000@access1.lan2wan.com>
On Thu, Jun 10, 1999 at 08:08:20PM -0400, Brett W. McCoy wrote:
> I seem to have a serious brain fart going here. I have two tables, and
> I want to find out which rows that are in the first do not have a match
> in the second. If I could create an explicit left join, I could do it by
> finding the rows in the second column that are NULL. Here's what I kinda
> have, but itjust sits there and never returns anything:
>
> select count(*) from apdf
> where apdf.doc_index != ondisk.doc_index;
This will return every row in the second table that doesn't math the
current row in the first table, for every single row in the first table.
That's roughly the product of the number or rows in the two tables.
What your looking for is:
select count(*) from apdf where apdf.doc_index not in
(select doc_index from ondisk);
Ross
>
> I tried the NOT IN operator (!!=), but it didn't like that at all. Is !=
> a valid operator?
>
> Brett W. McCoy
> http://www.lan2wan.com/~bmccoy
> -----------------------------------------------------------------------
> "Biology is the only science in which multiplication means the same
> thing as division."
>
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: reedstrm@wallace.ece.rice.edu
Subject: Re: [SQL] unmatched
In-Reply-To: <19990610163208.A878@wallace.ece.rice.edu>
References: <Pine.BSI.3.91.990610200217.15423B-100000@access1.lan2wan.com> <19990610163208.A878@wallace.ece.rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox