Sql Query for getting total number of empty fields in a row…

We can get total number of empty fields in a row in a table…


select SUM((`field1` = '') + (`field2` IS NULL) + ( `field3` = 0) + ...... (`fieldnth` = '')) from tablename where conditions;

Here we use
= ‘ ‘ for fields having field type string like varchar ,chars,text etc..
IS NULL is for field having default value NULL
= 0 is for field define integer type

Advertisements