mybatis 关于 if test 判断字符串的大坑
https://blog.csdn.net/chenaini119/article/details/51917263
还有XML文件 不能用> <来表达大于小于 。。 例如 grade>0 , grade<10
https://blog.csdn.net/zheng0518/article/details/10449549
老周一直遇到的bug
今天遇到的一个数据查询 的难题
就是统计 评价当前电影 各星星等级 的人数
问题:搜mysql 同一字段 相同的值 的条数
找到解决办法的博客:https://blog.csdn.net/eaphyy/article/details/71305422
我最后写出的语句是这样的:
select m.id,m.name,COALESCE(startb.one,0) as onestar,COALESCE(startb.two,0) as twostar,COALESCE(startb.three,0) as threestar,COALESCE(startb.four,0) as fourstar,COALESCE(startb.five,0) as fivestar from movie m LEFT JOIN (SELECT id,star,movie_id,sum(case star when 1 then 1 else 0 end) as one, sum(case star when 2 then 1 else 0 end) as two,sum(case star when 3 then 1 else 0 end) as three ,sum(case star when 4 then 1 else 0 end) as four ,
sum(case star when 5 then 1 else 0 end) as five from score where movie_id =5) as startb on startb.movie_id = m.id