pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13501: Bug with subqueries in WHERE clause
2+ messages / 2 participants
[nested] [flat]

* BUG #13501: Bug with subqueries in WHERE clause
@ 2015-07-15 11:12  me@egidiocaprino.it
  0 siblings, 1 reply; 2+ messages in thread

From: me@egidiocaprino.it @ 2015-07-15 11:12 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13501
Logged by:          Egidio Caprino
Email address:      me@egidiocaprino.it
PostgreSQL version: 9.3.6
Operating system:   Linux (don't know the distribution)
Description:        

This query returns one record

select *
from merge.organization
where school_id = 1000056

This query returns no record

select *
from merge.account
where school_id = 1000056

This query returns no record

select *
from merge.sd3_hierarchy
where school_id = 1000056

This query returns no record

select *
from merge.organization
where school_id not in (select school_id from merge.account)
or school_id not in (select school_id from merge.sd3_hierarchy)

So I have one organisation that does not exists in the account table and
does not exist in the sd3_hierarchy. The last should return at least one
record.


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



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

* Re: BUG #13501: Bug with subqueries in WHERE clause
@ 2015-07-15 15:28  Tom Lane <tgl@sss.pgh.pa.us>
  parent: me@egidiocaprino.it
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-07-15 15:28 UTC (permalink / raw)
  To: me@egidiocaprino.it; +Cc: pgsql-bugs

me@egidiocaprino.it writes:
> This query returns no record

> select *
> from merge.organization
> where school_id not in (select school_id from merge.account)
> or school_id not in (select school_id from merge.sd3_hierarchy)

This usually means that you've got NULLs in the school_id column.
NOT IN never returns true if there are any nulls in the sub-select result.
This is per SQL standard.

			regards, tom lane


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



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


end of thread, other threads:[~2015-07-15 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-07-15 11:12 BUG #13501: Bug with subqueries in WHERE clause me@egidiocaprino.it
2015-07-15 15:28 ` Tom Lane <tgl@sss.pgh.pa.us>

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