Query the implementation of consecutive days, how to handle
Source: Internet
Author: User
Query the implementation of consecutive days
I want to implement this feature
From the current time, backward query for consecutive days of time, if in the middle there is a not and the last time continuous, can not query information!
If can MySQL statement directly to achieve better, if can not use php+mysql also good
Please give my little sister a weapon here, just learn PHP and MySQL so is a rookie .... Thank you ....
------Solution--------------------
This can be achieved at the time of data design.
Use two fields the number of consecutive logons in the last logon time (default is 0)
The current date and last logon time are determined when the user logs on.
Case 0: If it's yesterday, it's connected. Current consecutive logon days + +
Case 1: If that's the day. is today. No updates
Case 2: If it was a few days apart. Reset to 0
Case 3: If the current time is smaller than the last logon time. You watch.
------Solution--------------------
Can be implemented in the MySQL stored procedure.
But the recommendations are straightforward to implement in PHP code.
------Solution--------------------
The first floor is more suitable for you.
------Solution--------------------
PHP Program Direct conditions to judge it!
------Solution--------------------
Build a field in the User table logins, a field lastdate
User login, read lastdate judge last day whether yesterday? If it is $logins= $logins +1; Update Lastdate for the current logon time. If the last logon time is not today or yesterday $logins=1; Restore changed to 1 consecutive login times
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service