| From: | yurikn(at)glas(dot)apc(dot)org (Yurik V(dot) Nazaroff) | 
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: [HACKERS] Subselects and NOTs | 
| Date: | 1998-02-21 22:31:48 | 
| Message-ID: | 6cnkkk$1cm$1@south-western.nazaroff.msk.ru | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Vadim B. Mikheev <vadim(at)sable(dot)krasnoyarsk(dot)su> wrote:
>  create table a (a int, a1 char(8));
>  create table b (b int);
>  insert into a values (1, 'one');
>  insert into a values (NULL, 'null');
>  insert into b values (1);
>  insert into b values (NULL);
>  select * from a where a in (select * from b);
>  -- 1 row with a == 1 expected
>  select * from a where a not in (select * from b);
>  -- 0 row expected
>  select * from a where not a in (select * from b);
>  -- 0 row in Oracle & Informix, 1 row in Pg (with a == NULL), SyBase ???
Should be 0 row(s) expected. Here's why: three-value logic.
a in (select...)
a == any (select...)
	(a=1) == (b==1) is 'true'
	(a=1) == (b==NULL) is 'unknown'
		'true' OR 'unknown' is 'true'.
	(a=NULL) == (b==1) is 'unknown'
	(a=NULL) == (b==NULL) is 'unknown'
		'unknown' OR 'unknown' is 'unknown'
		not ('unknown') is 'unknown'
		shouldn't be in 'where not a in...' query
Hope this helps.
--
Yurik
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Phil Thompson | 1998-02-21 23:26:52 | Tcl Implementation of crypt() | 
| Previous Message | Joao Leao | 1998-02-21 21:57:30 | [HACKERS] Unsubscribe |