Finding the negative

From: Ed Rouse <erouse(at)milner(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Finding the negative
Date: 2017-07-06 19:13:09
Message-ID: DE8D456CF535514BB21272D05C4A1C391E66AB2E@mbx029-e1-va-10.exch029.domain.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Version 9.1.
I have the following query that brings back the correct number of lobs still asscociated with data in other tables:

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

in that the loid's in either table are found. 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. This is all a prelude to removing lobs that are no longer referenced.

Any ideas on how to get the inverse of the working query? Thanks

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vincent Elschot 2017-07-06 19:25:20 Re: Finding the negative
Previous Message Saiful Muhajir 2017-06-20 01:48:17 Re: Find rows with "timestamp out of range"