[thelist] MySQL data typesL

noah noah at tookish.net
Wed Jan 16 20:39:37 CST 2002


At 07:34 PM 16/01/2002, Brent Rieck wrote:
>I believe that's where your problem is: "" is a zero length string
>(which MySQL will interpret as the numerical value 0), and NULL is,
>well, null - and they're *not* equivalent.  When inserting nulls specify
>the value as NULL with no quotes.  (in the "test" table from my previous
>email it would look like: "insert into test values (NULL);")

Thanks - that makes sense.

Seems like a bit of a hassle, though, since all inserts then need to be 
preceded with a bunch of these:

if ($foo == "") {
   $foo = NULL;
}

I'm sure that this is justified by some use to zero length strings (as 
opposed to nulls) in numerical columns that has just never occurred to me.

Cheers,
Noah





More information about the thelist mailing list