Home>

Thank you for watching.
I want to use the following SQL in PHP. How can I drop it and it will work without problems?

<? php
Applicable SQL
?>


After uploading, the page will not work.
I think it's probably different from the description method.

Corresponding source code
SELECT
    billdate, --slip date
    duedate, --Customer closing date (1-31)
    CASE
      WHEN duedate = 31 THEN DATE_FORMAT (billdate,'% Y year% m month') --The end is slip month = billing month
      WHEN duedate<31 AND DAY (billdate)<= duedate THEN DATE_FORMAT (billdate,'% Y year% m month') --Voucher date<= Voucher month = billing month
      WHEN duedate<31 AND DAY (billdate)>duedate THEN DATE_FORMAT (DATE_ADD (billdate, INTERVAL 1 MONTH),'% Y year% m month') --Voucher date other than the end date>Voucher month = billing The month after the month
    END AS monthly
FROM FROM
    earnings
    JOIN customers ON customers.id = earnings.customer_id
WHERE
    duedate>0
GROUP BY
    billdate, due date
What I tried

I looked it up, but I didn't get caught in the part of how to drop it, so I stumbled at the beginning.
I have no knowledge about SQL.

You may have heard something strange, but if i am familiar with it, I would appreciate your help.

  • Answer # 1

    A table that links the closing date for several years from the beginning with the start date and end date of the period
    It is easiest to make it.