Input:
col1
a,b
a,c
Output:
col1 count
a 2
b 1
c 1
I want to simply count multivalue rows in MySQL Query.
Input:
col1
a,b
a,c
Output:
col1 count
a 2
b 1
c 1
I want to simply count multivalue rows in MySQL Query.
If your "table" is a large table or view, then you can use cross join
to generate the rows with only one table reference:
select (case when n.n = 1 then col1 else col2 end) as col,
count(*)
from t cross join
(select 1 as n union all select 2) n
group by col;