title: how to select two columns from two different tables in mysql
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12956089/how-to-select-two-columns-from-two-tables-in-mysql">how to select two columns from two tables in mysql</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to execute this query but i got different output. I want
  to count row from one <code>column(grade</code>) from <code>table grading</code> and select
  <code>column(level)</code> from other <code>table info</code>.</p>
  
  <pre><code>for($i=1; $i&lt;9; $i++)
  {
  $result = mysql_query("SELECT COUNT(grade),level FROM grading,info WHERE grade = $i");
   while ($row = mysql_fetch_array($result))
   {
  
      echo "&lt;tr&gt;&lt;td&gt;";
      echo $row['level'];
      echo "&lt;/td&gt;";
      echo "&lt;td&gt;";
      echo  $row['COUNT(grade)'];
      echo "&lt;/td&gt;&lt;/tr&gt;";
   }
  }
  </code></pre>
  
  <p>my database:</p>
  
  <pre><code>      level   grade          
  
          A       1
          B       2
          C       6
          D       3
          E       4
          F       5
          G       6
          H       8
  </code></pre>
  
  <p>My output:</p>
  
  <pre><code>      level   grade     
          A       8
          B       8
          C       8
          D       8
          E       8
          F       16
          G       0
          H       8
  </code></pre>
  
  <p>but its wrong i want to count how many students have grade
  <code>1,2,3,4,5,6</code> but output display something else.</p>