title: mysql php subtract 2 fields from 2 tables Improving Query
body: <p>hi guys im trying to improve my query for better performance is it possible to write this query in better way thanks a lot your helps   </p>
  
  <pre><code>$query = " SELECT A  FROM out_org where zone_id='1'";
  $query2 = " SELECT A  FROM out_dis where zone_id='1'";
  
  $result = mysql_query($query);
  $result2 = mysql_query($query2);
  
  echo "&lt;table border=1 style='background-color:#F0F8FF;' &gt;";
  echo "&lt;caption&gt;&lt;EM&gt;my table&lt;/EM&gt;&lt;/caption&gt;";
  echo "&lt;tr&gt;";
  echo "&lt;th&gt;" .OA. "&lt;/th&gt;" ;
  echo "&lt;th&gt;" .DA. "&lt;/th&gt;";
  echo "&lt;th&gt;" .total. "&lt;/th&gt;";
  echo "&lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result)  )
  {
      while( $row2 = mysql_fetch_array($result2)){
          echo "&lt;tr&gt;";          
          echo "&lt;td&gt;" .$row['A']."&lt;/td&gt;";
          echo "&lt;td&gt;" .$row2['A']."&lt;/td&gt;";
          echo "&lt;td&gt;" .$total = $row['A'] - $row2['A']."&lt;/td&gt;";         
          echo "&lt;/tr&gt;";           
      }
      echo "&lt;/table&gt;";
  }
  </code></pre>