I want to replace 0's in mysql table with 'NULL'. I have read that querying the following way would replace 'NULL' with 0
SELECT COALESCE(null_column, 0) AS null_column FROM whatever;
But how to the other way?
You can use NULLIF
, which will return NULL
if the value in the first parameter matches the value in the second parameter.
SELECT NULLIF(null_column, 0) AS null_column FROM whatever
update `whatever` set `null_column` = null where null_column = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With