with t as( select staff_id, if(course like '%1%',1,0) as course1, if(course like '%2%',1,0) as course2, if(course like '%3%',1,0) as course3 from cultivate_tb where course is not null) select sum(course1)+sum(course2)+sum(course3) as staff_nums from t