Search

OakieTags

Who's online

There are currently 0 users and 36 guests online.

Recent comments

NULLs

Comparing Columns Containing NULL Values

Prompted by a (not really that) recent discussion on the OTN forum I've decided to publish this note.Sometimes you have the task of comparing column values and handling the NULL value cases correctly makes this rather cumbersome for columns that are allowed to be NULL.The "official" SQL way of comparing two column values and to find out whether they are equal or not - under the assumption that having NULL in both columns should be treated as equal (a point that can be argued) would read in SQL something like the following for the "unequal" case:


column1 != column2 or (column1 is null and column2 is not null) or (column1 is not null and column2 is null)

and