I have the following Mysql Table
Order table
status 0 - incomplete
status 1 - complete
PO_invoice| Company| transactionType| Amt_Paid | Balance | Status| dateCreated|
1001 | Astek | 3| 10000| 10000| 0 |2012-10-15 |
1002 | Asrack | 2| 20000| 0| 1 |2012-10-20 |
Transaction table
It contains the explanation of the mode of payment
- if type 1 then the full amount should be paid on the same day
- if type 2 then the 50% on same day and after
- 30 days other 50% amount should be paid
- if type 3 then the 60% on same day and after
-
60 days other 60% amount should be paid
transactionType | noDays | PercentSplit | 1| 0 | 0 | 2| 30 | 50 | 3| 60 | 60 |
I am trying to track the orders which are due for payment
currently i am joining the two tables on transaction type and status 0
$query = "select Order.PO_invoice, Order.Company, Order.Amt_Paid, Order.Balance,
Order.dateCreated, Transaction.noDays,Transaction.PercentSplit
INNER JOIN Transaction
ON Order.transactionType = Transaction.transactionType AND
Order.status =0"
and looping in PHP, and checking if the
currentTime - Order.dateCreated > = Transaction.noDays
if it is then display the row else skip the row.
I want to know whether there is a way to do this in MYSQL only and return only those rows.
have you tried –