Check empty mysql column

Asked

Viewed 70 times

1

I’m having trouble checking which columns are empty on mysql. I’m using the COALESCE but it only checks the first column of the sequence:

COALESCE(column1, column2, column3...) AS values

If column1 is empty it returns, but if column1 is filled and one of the others is empty it does not return which is empty, it only checks the first column. How can I check which column is position independent empty?

  • But this is exactly what the coalesce function is expected to do, which returns the first non-null element of the list. I think you need to do a column-by-column test.

  • Um, I will try to use CASE WHEN together with COALESCE, would it work @anonimo ?

  • I believe that an IFNULL(columnx, 'NULL') for each column is better. Maybe the interface you are using can be configured to display the 'NULL' string (or any string of your choice) when the contents of the field are NULL.

  • I will see about IFNULL @anonimo

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.