当我们选择存储在数据库中的多个值时,如下所示
现在我想计算值被选择的次数 从如上表
cloths 2 times
Electronics 2 times
Food 1 time
这怎么可能?
最佳答案
这样的事情可能会起作用:
select c.cat, count(t.answer)
from (select 'cloths' as cat union all
select 'electronics' union all
select 'food'
) c left outer join
table t
on t.answer like concat('%', c.cat, '%')
group by c.cat;
关于php - 获取 mysql 列字段中不同字符串值的计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25737286/