title: Query that show the value of two different columns php mysql
body: <p>i have two tables with fields and values:</p>
  
  <p>TABLE respostas</p>
  
  <pre><code>Id      Corp_resp            Id_perg     Id_quest 
  12       0,2                 1             1
  13       0,5                 2             1
  14       0,7                 3             1
  15       0,2                 4             1
  16       0,3                 5             1
  17       0,6                 6             1
  </code></pre>
  
  <p>Table menu</p>
  
  <pre><code>Id_perg         percentagemadministrador Id_quest
  1                             0.5        1    
  2                             0.4        1         
  3                             0.3        1          
  4                             0,2        1
  5                             0,1        1
  6                             0,8        1
  </code></pre>
  
  <p>I want to associate the <code>id_quest</code> to <code>id_perg</code> and multiply the <code>corp_resp</code> with <code>percentagemadministrador</code> of the last 10 rows of the table <code>respostas</code></p>
  
  <p><code>total=SUM(corp_resp*percentagemadministrador)</code> of the last 10 rows of the table.</p>
  
  <pre><code>&lt;?php
  mysql_connect("localhost","root","") or die(mysql_error());
  mysql_select_db("teste") or die(mysql_error()); // selecciona a database do server escolhido
  
  //something like that
  
  $query ="SELECT SUM(menu.percentagemadministrador*respostas.corp_resp) as TOTAL 
           FROM respostas 
           INNER JOIN menu 
           WHERE respostas.id_perg=menu.id_perg 
           AND respostas.id_quest=menu.id_perg 
           LIMIT id_perg=10";
  
  $resultado = mysql_query($query) or die(mysql_error());
  
  if($row = mysql_fetch_array($resultado)){
  
      echo " &lt;center&gt; Final: &lt;/center&gt; ".$row['TOTAL'];
  } ?&gt;
  </code></pre>
  
  <p>Can you help with that?</p>