I'm running a query in which I need to join two tables table_views and table_clicks. Both tables share several column names (mainly refId, month, year and total).
However when I try and join these tables together, instead of returning ~18 or 20 rows/records. It repeats the join for every single row, producing 360 records.
How can I query and combine both tables by their reference Id?
$records = craft()->db->createCommand() ->select('*') ->from('table_views table_views') ->leftJoin('table_clicks table_clicks', 'table_views.refId=table_clicks.refId') ->where('table_views.refId = :refId', array(':refId' => $id)) ->query();