Heim  >  Artikel  >  Backend-Entwicklung  >  mysql如何查今天登录了多少人

mysql如何查今天登录了多少人

WBOY
WBOYOriginal
2016-06-06 20:32:161031Durchsuche

每次登录都会生成一条log记录,包含登录时间和用户的userId
我应该怎么写sql才能查出 今天 都多少人登录过?
重复的userId不记录?

<code>"select count(*) from log_login where login_time > '{date('Y-m-d')}' "
</code>

不行呀。。

回复内容:

每次登录都会生成一条log记录,包含登录时间和用户的userId
我应该怎么写sql才能查出 今天 都多少人登录过?
重复的userId不记录?

<code>"select count(*) from log_login where login_time > '{date('Y-m-d')}' "
</code>

不行呀。。

<code>select count(DISTINCT userId) from log_login where DATE_FORMAT(login_time, '%Y-%m-%d')=DATE_FORMAT(now(), '%Y-%m-%d')
</code>

终于碰到 我能回答的问题了

where 时间 >= 2015-7-3 00:00:00 and 时间

应该就ok了

select count(distinct userid) from log_login where login_time >='今天' and login_time 或者用group by userid

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP的VLD插件未生效Nächster Artikel:php数组的数字key最大多少