Forums
This topic is locked
perform a row count through related tables
Posted 17 Aug 2008 20:37:08
1
has voted
17 Aug 2008 20:37:08 john henderson posted:
Hi Guys,I wonder if anyone can help me here, I have not quite solved my querie but on the other hand it does what I want.
I have 2 tables linked together, 1 customers 1 payments. I want to display the customers property details in a list, but also provide a count of each customers unpaid payments along side. see example
Bury Rd, Week1, Rnd1, Mon
No Code Job1 Paid1 Job2 Paid2 Debts
614 c m STD Cons 11
960 c m Fronts 1
B bull c m STD 3
Vanity hair c m STD Cons 2
The thing is I want to display all the customers even the ones with no debts, can you see where I am going wrong with my mysql code
SELECT *, Count(payments.paid) as counter
FROM payments, customers
WHERE customers.customerid=payments.customerid and payments.paid<>'1' and cust_street = colname
GROUP BY payments.customerid
ORDER BY cust_houseno
with appreciation
John Henderson