pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Some more weird NULL behavior
2+ messages / 2 participants
[nested] [flat]

* Some more weird NULL behavior
@ 2002-11-09 04:30 Ludwig Lim <lud_nowhere_man@yahoo.com>
  2002-11-09 05:13 ` Re: Some more weird NULL behavior Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Ludwig Lim @ 2002-11-09 04:30 UTC (permalink / raw)
  To: pgsql-sql

Hi:

  I tried the following:
  CREATE TABLE x(
       a  NUMERIC(5,0),
       b  VARCHAR(5)
  );

  CREATE TABLE y(
       a  INTEGER,
       b  VARCHAR(5)
  );

  INSERT INTO x(b) VALUES ('LUDZ');
  INSERT INTO y(b) VALUES ('TEST');

  SELECT x.b,y.b FROM x,y WHERE x.a=y.a 
  returns zero rows.

  However:
  SELECT b FROM x WHERE a IS NULL returns 'LUDZ'
  SELECT b from y WHERE a IS NULL returns 'TEST'

  I also tried
  SELECT x.b,y.b
  FROM x,y
  WHERE x.a = CAST(y.a AS INTEGER);

  But it also returns zero rows.


Thank you in advance,
ludwig.
  

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



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

* Re: Some more weird NULL behavior
  2002-11-09 04:30 Some more weird NULL behavior Ludwig Lim <lud_nowhere_man@yahoo.com>
@ 2002-11-09 05:13 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2002-11-09 05:13 UTC (permalink / raw)
  To: Ludwig Lim <lud_nowhere_man@yahoo.com>; +Cc: pgsql-sql

On Fri, 8 Nov 2002, Ludwig Lim wrote:

> Hi:
>
>   I tried the following:
>   CREATE TABLE x(
>        a  NUMERIC(5,0),
>        b  VARCHAR(5)
>   );
>
>   CREATE TABLE y(
>        a  INTEGER,
>        b  VARCHAR(5)
>   );
>
>   INSERT INTO x(b) VALUES ('LUDZ');
>   INSERT INTO y(b) VALUES ('TEST');
>
>   SELECT x.b,y.b FROM x,y WHERE x.a=y.a
>   returns zero rows.

A comparison of two NULL values does not
return true, it returns unknown.
If you want to say equal or both null you
should do it explitly.
(x.a=y.a) or (x.a is null and y.a is null)





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


end of thread, other threads:[~2002-11-09 05:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-09 04:30 Some more weird NULL behavior Ludwig Lim <lud_nowhere_man@yahoo.com>
2002-11-09 05:13 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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