I dont know if this is possible with one query, but here goes:
I have a column that is a set datatype. I want to select a count of each possible value of the set. So I have:
row 1 set column value: ‘opt 1′,’opt 2’
row 2 set column value: ‘opt 1’, ‘opt 3’
row 3 set column value: ‘opt 3′,’opt 4′,’opt 2’
I need a query that will produce a structure similar to (doesnt have to be exactly this, just a count for each possible value of the set):
Array(
[0] => Array(
'value'=>'opt 1',
'count'=> 2
),
[1] => Array(
'value'=>'opt 2',
'count' => 2
),
[2] => Array(
'value'=>'opt 3',
'count' => 2
),
[3] => Array(
'value'=>'opt 4',
'count' => 1
)
)
since your SET column is a bitmap, you could setup a query like this:
…