My database has got four columns: one, two, three and four each one has the type SET('a','b','c','d').
I want to know how many times a, b, c and d occurs in each column.
I guess I could do something like this
SELECT
(SELECT COUNT(*) FROM database as d WHERE d.a = 'one') AS one,
(SELECT COUNT(*) FROM database as d WHERE d.a = 'two') AS two,
(SELECT COUNT(*) FROM database as d WHERE d.a = 'three') AS three,
(SELECT COUNT(*) FROM database as d WHERE d.a = 'four') AS four
FROM database
LIMIT 1
four times which I know would work. Or I could fetch the entire result and count what's in the array.
Can I somehow do this more efficient?
Thanks