From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ed Rouse <erouse(at)milner(dot)com> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Finding the negative |
Date: | 2017-07-06 19:43:23 |
Message-ID: | 26802.1499370203@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Ed Rouse <erouse(at)milner(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kanjibhai.Kanzaria | 2017-07-10 12:49:06 | Function with table Valued Parameters execution issue |
Previous Message | Vincent Elschot | 2017-07-06 19:25:20 | Re: Finding the negative |