I had to struggle yesterday to figure out how to find dormant players in the game. Dormant players are those who have not logged in for a certain period of days, 30 days in my case. Decided to make a post so that it may help someone in the future and also so that anyone can improve upon my implementation.
Every time a user logins to the game, the userid & the time of login is stored in a table called "logins", as such:
INSERT INTO logins(id_user,time_login) VALUES ('$user_id',NOW())
The userid & other user details are stored in a table called "users".
To view all users who have not logged during the past 30 days, the following query can be used:
SELECT user_id FROM users WHERE user_id NOT IN (SELECT id_user FROM logins WHERE DATEDIFF(CURDATE(), time_login) < 30)
This may not be the best way to do it, so anyone with a better way of doing this, please feel free to post their implementation.