I'm trying to find a pure MySQL way of doing this to avoid a lot of repeat / similar PHP scripts.
Say I select a single row in my table it could look like this:
| col1 | col2 | col3 | col4 | col5 | col6 |
| abc |b b a | '%kj | jh | | |
I want to COUNT how many columns in that row are not empty. So in this example it is 4.
I came up with a solution where I run a count query where col1 is not empty for id=X, and then run this 6 times and add up the results. However I feel this is surely very inefficient and I couldn't think of a better way of doing it.
Does anybody have any idea how I could make that more efficient?