title: Getting a difference between a sum of row from 2 different tables
body: <p>I have two tables, I am trying to get the sum of the amount paid which is in one table from sum of monthly_cost that is in another table. Its not giving me a result. I need help from you colleagues. Below is the code</p>
  
  <pre><code>$sql=mysql_query("select sum(monthly_cost) as overallmc from link");
          $row=mysql_fetch_assoc($aql);   
          $r=mysql_query("select sum(amount_paid) as total  from link_logs where date_of_execution BETWEEN '$sDate1' AND '$sDate2'");  
          $rows=mysql_fetch_assoc($r);
  
          $ronald=$row['overallmc']- $rows['total'];
          echo $row['overallmc']; 
  </code></pre>