pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: [SQL] unmatched
4+ messages / 4 participants
[nested] [flat]

* Re: [SQL] unmatched
@ 1999-06-10 21:32  Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
  parent: Brett W. McCoy <bmccoy@lan2wan.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Ross J. Reedstrom @ 1999-06-10 21:32 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] unmatched
@ 1999-06-11 00:02  Chris Bitmead <chris@tech.com.au>
  parent: Brett W. McCoy <bmccoy@lan2wan.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Chris Bitmead @ 1999-06-11 00:02 UTC (permalink / raw)
  To: pgsql-sql

"Brett W. McCoy" wrote:

> I tried the NOT IN operator (!!=), but it didn't like that at all.  Is !=
> a valid operator?

Do you mean <> ?

-- 
Chris Bitmead
mailto:chris@tech.com.au
http://www.techphoto.org - Photography News, Stuff that Matters



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* unmatched
@ 1999-06-11 00:08  Brett W. McCoy <bmccoy@lan2wan.com>
  0 siblings, 3 replies; 4+ messages in thread

From: Brett W. McCoy @ 1999-06-11 00:08 UTC (permalink / raw)
  To: pgsql-sql

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;

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."




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] unmatched
@ 1999-06-11 15:49  José Soares <jose@sferacarta.com>
  parent: Brett W. McCoy <bmccoy@lan2wan.com>
  2 siblings, 0 replies; 4+ messages in thread

From: José Soares @ 1999-06-11 15:49 UTC (permalink / raw)
  To: Brett W. McCoy <bmccoy@lan2wan.com>; +Cc: pgsql-sql

prova=> select * from  prova1;
a1
-----
delta
alpha
gamma
(3 rows)

prova=> select * from  prova2;
a2
-----
delta
gamma
(2 rows)

prova=> select * from  prova1 where a1 not in (select * from prova2);
a1
-----
alpha
(1 row)



"Brett W. McCoy" ha scritto:

> 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;
>
> 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."

______________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-06-11 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-11 00:08 unmatched Brett W. McCoy <bmccoy@lan2wan.com>
1999-06-10 21:32 ` Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
1999-06-11 00:02 ` Chris Bitmead <chris@tech.com.au>
1999-06-11 15:49 ` José Soares <jose@sferacarta.com>

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