问题描述
现在有个需求要我查出来今天登录了1,2,3,4,5,6,7,8,9,10次的用户。我自己写了个存储过程要查询好几个好事,太慢了。用group by 怎么查啊?select playerId from log_login where loginTime>=current_date() and loginTime<date_add(curdate(),interval 1 day) and areaId=1 group by loginTime having count(loginTime)=2;查出来的用户有登录次数大于2的,也有小于2的。不对啊。我该怎么改啊? 问题补充:哇塞。。。原来把group by loginTime改成 group by playerId就可以了。。。
解决方案
select playerId from log_login where loginTime>=current_date() and loginTime<date_add(curdate(),interval 1 day) and areaId=1 group by playerId having count(playerId )>2;
时间: 2024-10-31 03:02:36