i have 2 tables as follow
sales (table1)
sales_id, userid(buyerid), product id, productname, orderid, status
users (table2)
userid, username, pass
Now, I need to display the top customer who makes regular purchase on my shopping site.
How can I achieve this?
I tried as
SELECT A.(*), B.username FROM sales A, users B WHERE A.userid=B.userid AND A.status='delivered';
Now, the same has to be looped and shown as top 10 buyers with the username, need to know how to loop too
Need experts advice on this, thanks