$result = mysql_query("SELECT SUM(`downloads`) AS total_downloads, SUM(`votes`) AS total_votes, SUM(`demos`) AS total_demos, SUM(`views`) AS total_views FROM theme_stats_by_day WHERE 1 AND `day` BETWEEN $start_date AND $end_date GROUP BY `theme_id` ORDER BY total_downloads DESC LIMIT $start,12") or die(mysql_error()); Code (markup): how do I add a left join to get things from my "themes" table such as name, id and other things associated with the theme?
You need to give information about where to Join the table i mean both of your tables do have some common column ?
$result = mysql_query("SELECT SUM(`downloads`) AS total_downloads, SUM(`votes`) AS total_votes, SUM(`demos`) AS total_demos, SUM(`views`) AS total_views FROM theme_stats_by_day LEFT JOIN themes ON theme_stats_by_day.theme_id = themes.id WHERE 1 AND `day` BETWEEN $start_date AND $end_date GROUP BY `theme_id` ORDER BY total_downloads DESC LIMIT $start,12") or die(mysql_error()); .. for example