Skip to content
Advertisement

mysql error “ Operand should contain 1 column(s)” when count occurrences in multiple columns

I want to get occurrences in multiple columns and count null values as zeros.

I have tried this.

but it returns error “Operand should contain 1 column(s)”

Advertisement

Answer

I think you want:

That is, you don’t want to “count NULL values as 0s” (whatever that means. You want to include ids that have no 3 in the result set with a 0 count.

I should note that forpas’s answer on your previous question is the right way to solve this problem. There is no need to aggregate over the entire dataset — that can be an expensive operation.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement