On Sat, Jan 12, 2002 at 01:45:48AM +0100, M.W. Koskamp wrote:
> 
> ----- Original Message ----- 
> From: "Ronald J Kimball" <[EMAIL PROTECTED]>
> To: "M.W. Koskamp" <[EMAIL PROTECTED]>
> Cc: "Ronnie Anderson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Friday, January 11, 2002 11:50 PM
> Subject: Re: dbi and nulls
> 
> 
> > 'foo' is not a column, 'foo' is a value.
> > 
> > The SQL will be either:
> > 
> > domain = 'foo' OR ( 'foo' IS NULL AND domain IS NULL )
> > 
> Dunno what database you are passing it to.
> But oracle will say you dont have a column foo.

It's obvious that you never tried it, since it works exactly as both I and
the original poster described.  The word foo is surrounded by single
quotes, which means it is a literal value and not the name of a column.

Here's an example, in Oracle:

09:18:18 FOXP> create table mytable (domain varchar2 (6));

Table created.

09:18:22 FOXP> insert into mytable values ('foo');

1 row created.
 
09:18:35 FOXP> insert into mytable values (NULL);
 
1 row created.

09:18:42 FOXP> select * from mytable;

DOMAIN
-------
foo
<empty>

09:18:42 FOXP> select * from mytable where domain = 'foo' or ( 'foo' is null and 
domain is null );
 
DOMAIN
-------
foo
 
09:19:15 FOXP> select * from mytable where domain = null or ( null is null and domain 
is null );
 
DOMAIN
-------
<empty>
 


> If you are really checking the value then your statement is redundant.

No, it is not redundant, because comparing any value to NULL with = returns
false, even if both values are NULL.  The only way to compare a value to
NULL is with IS NULL.

09:21:41 FOXP> select * from mytable where domain = null;
 
no rows selected

09:24:28 FOXP> select * from mytable where domain is null;
 
DOMAIN
-------
<empty>


Ronald

Reply via email to