扫码关注官方订阅号
每次登录都会生成一条log记录,包含登录时间和用户的userId 我应该怎么写sql才能查出 今天 都多少人登录过? 重复的userId不记录?
"select count(*) from log_login where login_time > '{date('Y-m-d')}' "
不行呀。。
欢迎选择我的课程,让我们一起见证您的进步~~
select count(DISTINCT userId) from log_login where DATE_FORMAT(login_time, '%Y-%m-%d')=DATE_FORMAT(now(), '%Y-%m-%d')
终于碰到 我能回答的问题了
where 时间 >= 2015-7-3 00:00:00 and 时间 <= 2015-7-3 23:59:59 group user_id
应该就ok了
select count(distinct userid) from log_login where login_time >='今天' and login_time<='明天' 或者用group by userid
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
终于碰到 我能回答的问题了
where 时间 >= 2015-7-3 00:00:00 and 时间 <= 2015-7-3 23:59:59 group user_id
应该就ok了
select count(distinct userid) from log_login where login_time >='今天' and login_time<='明天'
或者用group by userid