I need to count and return the number of NULL columns in my MySQL query.
SELECT * from posttracks WHERE trackid=100000;
How would I COUNT
all NULL
columns?
Edit: to be clear, I don't need the number of rows that have null values, I need the number of columns in the row that have NULL
values.
If I understand your question correctly:
SELECT ISNULL(col1) + ISNULL(col2) + ... + ISNULL(col16) AS cnt
FROM yourTable
WHERE trackid=100000
SELECT count(*) from posttracks WHERE Col1 is NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With