Q:

How to get number of columns which are blank or null values or 0 from mysql table

I want to get the number of column from MySQL table which has no values, means which are blank or zero.
Actually, I want to measure the employee profile that how many fields he has filled and how many are left?
I am using MySQL with PHP.

A:

I don't see any way of doing this other than to manually sum every column.  Here is a somewhat concise way of doing this:
SELECT
    empId,
    IF(COALESCE(col1, '') = '', 1, 0) +
    IF(COALESCE(col2, '') = '', 1, 0) +
    ...
    IF(COALESCE(colN, '') = '', 1, 0) AS num_cols_missing
FROM yourTable;

We can replace NULL columns values with empty string, and then compare that result to empty string.  This means we can check for both NULL and empty with a single logical expression.

