title: Temp tables vs subqueries in inner join
body: <p>Both SQL, return the same results. The first my joins are on the subqueries the second the final queryis a join with a temporary that previously I create/populate them</p>
  
  <pre><code>SELECT COUNT(*) totalCollegiates, SUM(getFee(c.collegiate_id, dateS)) totalMoney
  FROM collegiates c
  LEFT JOIN (
      SELECT collegiate_id FROM collegiateRemittances r
      INNER JOIN remittances r1 USING(remittance_id)
      WHERE r1.type_id = 1 AND r1.name = remesa   
  ) hasRemittance ON hasRemittance.collegiate_id = c.collegiate_id
  WHERE hasRemittance.collegiate_id IS NULL AND c.typePayment = 1 AND c.active = 1 AND c.exentFee = 0 AND c.approvedBoard = 1 AND IF(notCollegiate, c.collegiate_id NOT IN (notCollegiate), '1=1');
  
  
  
  DROP TEMPORARY TABLE IF EXISTS hasRemittance;
  
  CREATE TEMPORARY TABLE hasRemittance
      SELECT collegiate_id FROM collegiateRemittances r
      INNER JOIN remittances r1 USING(remittance_id)
      WHERE r1.type_id = 1 AND r1.name = remesa;
  
  SELECT COUNT(*) totalCollegiates, SUM(getFee(c.collegiate_id, dateS)) totalMoney
  FROM collegiates c
  LEFT JOIN hasRemittance ON hasRemittance.collegiate_id = c.collegiate_id
  WHERE hasRemittance.collegiate_id IS NULL AND c.typePayment = 1 AND c.active = 1 AND c.exentFee = 0 AND c.approvedBoard = 1 AND IF(notCollegiate, c.collegiate_id NOT IN (notCollegiate), '1=1');
  </code></pre>
  
  <p>Which will have better performance for a few thousand records?</p>