I have a table with lots of columns, and I want to quickly figure out which columns are empty (full of NULL). I'm not sure how to loop over the columns of the table, so I first put the column names into a temporary table like so:
CREATE TEMPORARY TABLE columnnames
SELECT column_name FROM information_schema.columns WHERE
table_name='table';
Then I tried to do a SELECT to get only the columns that had COUNT=0:
SELECT * FROM columnnames WHERE ( SELECT COUNT(column_name) FROM 'table' ) > 0
The syntax doesn't check out though and I'm not sure how to get it working. Is there a better way to loop over the columns to find which ones are empty?