For SQL, we can extract all column names from information_schema. Then concatenate the column names with ‘IS NULL’ in where clause to get the number.
SET @query = CONCAT(
'SELECT COUNT(*) FROM sakila.staff WHERE CONCAT(',
(SELECT GROUP_CONCAT(COLUMN_NAME)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'sakila' AND
TABLE_NAME = 'staff'),
') IS NULL');
PREPARE CHECK_NULL from @query;
EXECUTE CHECK_NULL;
-
This reply was modified 3 years, 9 months ago by Wong.