I’m having some issues with a mysql query.
I’m trying to join together multiple tables.
In one table, I have a list of successful online customers, and on another table I have a table which has the traffic source from which it came. I’m trying to track which customers came from a certain ad. So I want to query those new customers who came on a certain date and from a specific campaign.
SELECT keyword, COUNT(keyword) FROM in_clicks AS ic WHERE ic.create_date LIKE '%2011-08-19%' GROUP BY ic.keyword ORDER BY COUNT(ic.keyword) DESC
INNER JOIN leads AS l ON ls.lead_id = l.id
INNER JOIN lead_status AS ls ON ls.lead_id = ls.id
INNER JOIN ads AS a ON ic.ad_id = a.id
INNER JOIN ad_groups AS ag ON a.ad_group_id = ag.id
INNER JOIN campaigns AS c ON ag.campaign_id = c.id;
I ran the above code and got the following error.
Error Code: 1064
'INNER JOIN leads AS l ON ls.lead_id = l.id Innner Join lead_status AS ls' at line 2
This should run better :-).
The order is: SELECT .. FROM … JOIN … WHERE … GROUP BY .. HAVING .. ORDER BY .. LIMIT