Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Null joins
Tue, Mar 7 2006 12:06 AMPermanent Link

Oliver Bock
In DBISAM, comparing NULL to itself returns TRUE.  Under normal
circumstances this presents few problems for me, although it begs the
question of why "is null" exists.

However when chaining left outer joins, it can lead to strife and an
explosion of unwanted results.  e.g.

select *
  from T1
  left outer join T2 on T1.ID = T2.ID
  left outer join T3 on T2.Other = T3.Other

If T3.Other is sometimes NULL and the first join fails, then the second
join will succeed, although this is unlikely to be what was intended!

A bit of unscientific research using Google suggests that Sybase, MS SQL
Server and MySQL all consider the result of NULL = NULL to be NULL,
rather than TRUE.

Why does DBISAM work as it does?  Is this one of those situations that
the standards are silent on?


  Oliver
Tue, Mar 7 2006 3:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Oliver,

<< In DBISAM, comparing NULL to itself returns TRUE.  Under normal
circumstances this presents few problems for me, although it begs the
question of why "is null" exists.

However when chaining left outer joins, it can lead to strife and an
explosion of unwanted results.  e.g.

select *
  from T1
  left outer join T2 on T1.ID = T2.ID
  left outer join T3 on T2.Other = T3.Other

If T3.Other is sometimes NULL and the first join fails, then the second
join will succeed, although this is unlikely to be what was intended!

A bit of unscientific research using Google suggests that Sybase, MS SQL
Server and MySQL all consider the result of NULL = NULL to be NULL, rather
than TRUE.

Why does DBISAM work as it does?  Is this one of those situations that the
standards are silent on? >>

No, the standards are quite clear that NULL = NULL should return NULL.  I'll
have to look into this further and see what the reasons are, because I
believe that compatiblity with ranges has something to do with it.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Mar 7 2006 3:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Oliver,

It's because we allow for using the = operator with NULLs like this:

MyField = NULL

This is a legacy thing from back before we allowed IS NULL with filters, and
the filters are the underlying basis for the joins, WHERE clause, etc.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Mar 7 2006 4:20 PMPermanent Link

Oliver Bock
Tim Young [Elevate Software] wrote:
> It's because we allow for using the = operator with NULLs like this:
>
> MyField = NULL
>
> This is a legacy thing from back before we allowed IS NULL with filters, and
> the filters are the underlying basis for the joins, WHERE clause, etc.

I guess you won't want to break existing code by changing the behavior
in WHERE clauses and filters, but what about in JOINs?  How about in v5?


  Oliver
Wed, Mar 8 2006 12:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Oliver,

<< I guess you won't want to break existing code by changing the behavior in
WHERE clauses and filters, but what about in JOINs?  How about in v5? >>

Version 5 has ANSI standard SQL NULL compliance.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Mar 8 2006 1:16 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Hisss Boooo

Roy Lambert
Thu, Mar 9 2006 3:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Hisss Boooo >>

That I can handle.  Just no more 300-post threads about the NULLs. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Image