agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ed Rouse <erouse@milner.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Finding the negative
Date: Thu, 06 Jul 2017 15:43:23 -0400
Message-ID: <26802.1499370203@sss.pgh.pa.us> (raw)
In-Reply-To: <DE8D456CF535514BB21272D05C4A1C391E66AB2E@mbx029-e1-va-10.exch029.domain.local>
References: <DE8D456CF535514BB21272D05C4A1C391E66AB2E@mbx029-e1-va-10.exch029.domain.local>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Ed Rouse <erouse@milner.com> writes:
> ... What I need is to find the ones NOT in either table. I have tried using not in both with or/and  and various parenthesis. I tried:

> select count(distinct(loid)) from pg_largeobject where not ((loid in (select content from attachments) or loid in (select content from idw_form_workflow_attachments)));

> This should work since, if the loid is not in the content of either table, it should be F or F = F, negated to T;
> which I would think would then count, but I get back 0 instead of the rather large number I should get.

I'm suspicious that this means there's at least one NULL in those content
columns.  That will cause the IN check to return either TRUE or NULL, not
FALSE.  You could recast to use EXISTS, or explicitly exclude nulls while
selecting from the attachments tables.

			regards, tom lane


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (3+ messages)

Message-ID: <26802.1499370203@sss.pgh.pa.us>
Permalink:  ../26802.1499370203@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26802.1499370203@sss.pgh.pa.us

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, erouse@milner.com
  Subject: Re: Finding the negative
  In-Reply-To: <26802.1499370203@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox