Can anyone please help me get the count of the filled MySQL columns?
For example:
My Table Structure:
ID | FName | LName |
---|---|---|
1 | ABC | NULL |
2 | XYZ |
In the above table, I have two Rows, and both rows contain one Null and One Empty Value, I just need to get the Count of each row that doesn’t have NULL
OR EMPTY
Value for a specific ID
.
Expected Result:
WHERE ID=1, the result would be:
Count = 2 (ID, FName)
WHERE ID=2, the result would be:
Count = 2 (ID, LName)
**I want to use this in WordPress
2
Answers
So, after searching for an hour or two.
I'm using this as my solution but I'm not sure if it's good regrading the optimization. Here is what I'm using: