mateo’s musings

people use the word “musings” waaay too much

Change (null) to 0

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!

Filed under: MySQL, Software , , ,

Leave a Reply