I have two tables, customers and accounts.
The customers table contains the usual and the accounts table contains all transactions for every customer, referenced by the custid.
What I am trying to do is find the last bill that each customer paid. Here is the code I have so far:
Code: Select all
SELECT * FROM accounts, customers WHERE accounts.custid=customers.id AND accounts.type=1 AND accounts.billpaid='Yes' ORDER BY accounts.billto DESC, accounts.custidI'm sure it's simple but I've been banging my head against a brick wall...