Ok folks, im sorry to ask about this since ive seen a couple of mysql JOIN examples but i seem to be unable to get it to work.
"sales"
----------------------
idcustomer | datecode
----------------------
1 | 20120503
1 | 20120503
1 | 20120503
2 | 20120503
3 | 20120503
I want to know who is the top buyer.... in terms of HOW MANY TIMES a customer buys something from me on a especific day (yes i use some weird format for date i know, please nevermind that)...so i do:
SELECT idcustomer, COUNT(idcustomer) FROM sales WHERE datecode = 20120503 GROUP BY idcustomer ORDER BY COUNT(idcustomer) DESC
AND I GET:
-----------------------------
idcustomer | Count(idcustomer)
-----------------------------
1 | 3
2 | 1
3 | 1
Question is... since i also have the table:
"customer"
----------------------
| name | id_customer |
----------------------
Jess | 1
Matt | 2
Perry | 3
And below is what i would like to achieve.... how to do so?
---------------------------------------------
customer.name | idcustomer | Count(idcustomer)
---------------------------------------------
Jess | 1 | 3
Matt | 2 | 1
Perry | 3 | 1