Javascript-mysql seven-day payment

Source: Internet
Author: User
Keywords Php javascript java mysql
Paylog Table Date UserID Todaypay
Now I'm going to look for a sevendaypay.

is to add the sum of nearly seven days per UID for each date and the best one SQL can handle

Reply content:

Paylog Table Date UserID Todaypay
Now I'm going to look for a sevendaypay.

is to add the sum of nearly seven days per UID for each date and the best one SQL can handle

It's like that. (Thanks to Rebiekong's reminder)

What you need is a function subdate ()

select sum(todayPay) as subPay from paylog where date >= unix_timestamp(DATE_SUB(curdate(),INTERVAL 6 DAY))  group by uid

Of course, if you want to work with PHP, you can calculate the current time minus 7 days/6 days of timestamp, and then put in SQL replace it.

SELECT * from article WHERE date_sub (Curdate (), INTERVAL 7 day) <= date ( add_time );
You can refer to PHP programmer Rechesson's Blog: http://www.leixuesong.cn/2065

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.