Skip to content

Change (null) to 0

July 17, 2008
tags: , ,

I was googling and  looking through forums trying to find how to set a (null) field to be 0 in MySQL, and for some reason had a really hard time finding it (maybe it’s just too basic for most people).  In any case, i’m posting the (very simple) solution here in case I need to find it again quickly, and in case it can help someone else.

UPDATE `TableName` SET `FieldName` = 0 WHERE `FieldName` IS NULL;

That’s all folks!

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: