I'm making money lending system. On that I use mysql database. I want to find customer's who skipped their daily instalment. I try this code. But It has error.
Prveious code:
SELECT l.loan_id, l.custormer_id,custormer_name FROM loan l
JOIN income i ON l.loan_id = l.loan_id
WHERE l.loan_id NOT IN (SELECT loan_id FROM income WHERE date_received = curdate()) and loan_status = 'not finish'
I have CUSTOMER,LOAN,INCOME tables. On customer table it holds all deatails of custormers. On loan table it holds all details of loans. On income table there are columns which named receipt_no, customer_id,loan_id,date_received and amount.
Above PREVIOUS CODE show all records not in today date (using 'CURDATE').
Think like this,
On income table, it had 100 records on 2016-01-01
WHEN I run PREVIOUS CODE on 2016-01-02 ; it show all the records on 2016-01-01. But I want isn't this.
At that time problem that results viewing all records of income instead I only want to get one name per one time.
Any Idea to resolve this ????