On Fri, Jan 11, 2002 at 10:05:56PM +0100, M.W. Koskamp wrote:
> 
> ----- Original Message ----- 
> From: "Ronnie Anderson" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 11, 2002 8:36 PM
> Subject: dbi and nulls
> 
> 
> <snip> 
> > my $hosthandler = $dbh->prepare(q{
> >  SELECT id
> >  FROM host
> >  WHERE tid = ?
> >  AND (domain = ? OR (? IS NULL AND domain IS NULL))
> What are you binding to the second ? here?
> There should be a column name there i think.
> What are you tring to test.
> Let's assume $DOMAIN contains 'foo'
> Using binding below the statement will be:
> domain = 'foo' OR ( 'foo' IS NULL AND domain IS NULL)
> I dont think you have a column foo.

'foo' is not a column, 'foo' is a value.

The SQL will be either:

domain = 'foo' OR ( 'foo' IS NULL AND domain IS NULL )

or:

domain = NULL OR ( NULL IS NULL AND domain IS NULL )

The reason for this approach is that NULL = NULL is false, not true, as
Ronnie mentioned in the original message.

Ronald

Reply via email to