mysql中如何统计某字段里某个字符的个数?
如我的表order里有一个字段order_num,里面存的是一些订单号,形式如“od_135484315315431541541”,现在我要统计这个订单号有多少个8,如出现4个8就算中奖,请问如何把这些数据查找出来?
------解决方案--------------------select length(order_num)-length(replace(order_num,'8',''))
------解决方案--------------------SQL code
select length(order_num)-length(replace(order_num,'8',''));