Mysql字段用逗号分割成两条数据

it2023-05-14  72

suppliertype 字段是有逗号的

统计有几个stInjection,几个stMould

把suppliertype换成自己的字段

select sum(a.value) value, a.suppliertype from ( select a.value,substring_index(substring_index(a.suppliertype,',',b.help_topic_id+1),',',-1) suppliertype from ( select count(a.id) value, a.suppliertype from trd_company a where a.pid is not null and a.authtype = 'utSupplier' and a.suppliertype is not null group by a.suppliertype -- 把该处换成自己的表 ) a join mysql.help_topic b on b.help_topic_id < (length(a.suppliertype) - length(replace(a.suppliertype,',',''))+1) order by a.value )a group by a.suppliertype
最新回复(0)