views:

45

answers:

1

Hello,

I was having issues with an INT field where there may be no value, a zero value, or an integer above zero and since

SELECT foo FROM bar where foo = ''

evaluates identically to

SELECT foo FROM bar where foo = 0

I redefined foo like to foo INT(11) NULL so that rows where no value for foo is supplied do not get selected by either foo = 0 or foo = '' but only by foo IS NULL

Is this a Good Way to deal with a difference between no value and a zero value?

TIA

JG

+7  A: 

Yes; nulls are the correct way to specify that a field has no value.

James McNellis