I am trying to join three MySQL tables in the same DB and I am having some difficulty.
I have separated this into two SQL statements that work. Can someone help me put them together?
This one gives me the totals for each affiliate and the join gives me the affiliate name and company:
"SELECT SUM(lineitemtotal), affiliateid, users.namefirst, users.namelast, orders.site FROM orders LEFT JOIN users ON orders.affiliateid=users.id WHERE orders.affiliateid > 0 AND orders.site = "bet" GROUP BY affiliateid;"
This one gives me a count of clicks for each affiliate. This is the one I want to join to the one above:
'SELECT aid, COUNT(*) FROM affiliatelog WHERE site = "bet" GROUP BY aid;'
I need to join the second statement to the first.