Home:ALL Converter>mysql select empty fileds but exclude 0 valued fields

mysql select empty fileds but exclude 0 valued fields

Ask Time:2018-09-17T23:03:47         Author:saurus

Json Formatter

In a mysql database, I need to match records that have empty fields and replace them with NULL so I am running the following query:

UPDATE table_name SET col_name=NULL WHERE col_name='';

This works but it also matches fields with value 0, how can I change this query to match only empty fields and ignore fields with value 0 ? ..or maybe is there a better way to do this?

Author:saurus,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52370694/mysql-select-empty-fileds-but-exclude-0-valued-fields
yy