Getting rank today, this week and this month
Posted by mahmud ahsan Filed Under MySQL with No Comments
In my previous article I’ve shown how to get rank using mysql query. Now I’m showing how to retrieve result based on today, week and month using mysql query. Actually I also implemented this in my quiz project so I’m sharing this with you.
For the table structure please look my previous article http://thinkdiff.net/mysql/how-to-get-rank-using-mysql-query/
Task 1: I’ve to retrieve those users rank who played the game today.
Solution: Look at the query
SELECT uid, participated, correct, wrong from quiz_user
WHERE DAYOFMONTH(CURDATE())=extract(day from updated)
ORDER BY correct DESC, participated ASC
limit 30

Someday ago i was working 2 facebook projects. When I was working on the 2nd facebook project, I just copied the first project architecture. Then I setup the mysql user account for the second project. As the two projects are similar, I thought to remain the username for mysql same for the 2 projects, but when I did that I created a great mistake that I’m describing here.





