Replace null with 0 in MySQL

Viewed 127452

I am getting NULL values in the results of an operation in MySQL.

Is there a way to convert the NULL values into the value 0?

6 Answers

If you messed up and have NULLs in existing table layout and want zeros, here is solution:

UPDATE `table` SET `somefield`=0 WHERE `somefield` is null

you can put the 0 value into your insert input method by casting it:(int)0

Related