(sorry for bad english and poor skill) Hello! I've got a mysql database which contains four columns and a cron job as a script, which requesting a status of a user every 10 minutes. DataBase columns:
ID UID STATUS CHECK_AT
Logic: every 10 minutes script is checking specific UIDs (written in other table) for online (1) or offline (0). What I;m trying to do: To output summary online time of specific UIDs for a day; week; month etc
I guess it should be elementary, like
select count(id) from DB_NAME where date(check_at) = '2013-10-01';
for a one day
select count(uid) from user_activity where date(check_at) between '2013-10-01' and '2013-10-07';
For a few days and so on.
But, my skill is to low to know, how I can count only online time (status=1) for a date. Can you give me some advices, please?
you could add your conditions in WHERE
clause like:
select count(id) from your_table where date(check_at) = '2013-10-01' AND status = 1;
OR
select count(uid) from user_activity where
date(check_at) between '2013-10-01' AND '2013-10-07'
AND status = 1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.