I have a member table
member_Id
member_Firstname
another table Paymentschedules
paymentschedule_Id
member_Id
paymentsc开发者_如何学Pythonhedule_amountdue values(100 rs,200rs)
paymentschedule_amonutpaid values (30 rs,40 rs)
paymentschedule_ActualDatetobepaid values(2011-02-03,2011-02-01,2011-03-01)
paymentschedule_ datepaid values like(2011-09-12,2011-08-10,2011-11-12,2010-08-01)
My problem is can i get the members firstname who are overdue upto "today" taking into account these values "ActualDatetobepaid" and "amonutpaid " and "amountdue" and "datepaid"
Can any one help on this one
Your last request, "Add 7 days", is solved by adding 7 days to J0HN's solution:
SELECT DISTINCT member_Firstname
FROM member m
JOIN Paymentscedules p ON p.member_id = m.member_id
WHERE DATE_ADD(paymentschedule_ActualDatetobepaid, INTERVAL 7 DAY)< NOW()
AND paymentschedule_amountdue > paymentschedule_amonutpaid
Not sure I understand columns' meanings, but try this:
select distinct member_Firstname
from member m
join Paymentscedules p on p.member_id = m.member_id
where paymentschedule_ActualDatetobepaid<now() and paymentschedule_amountdue > paymentschedule_amonutpaid
If you could provide data types user for that columns and column meanings I could come up with more precise solution.
精彩评论