title: Magento join tables
body: <p>i need make a join costum tables in my query.
  I need to do a cycle of all products ordered by categories of "entity_id" and join this select if is valid</p>
  
  <pre><code>SELECT *,
      pps_product_id, 
      MIN(pps_last_unit_price) AS pps_last_unit_price, 
      pps_quantity_product
      FROM
      ".Mage::getSingleton('core/resource')-&gt;getTableName('purchase_product_supplier')."
      WHERE
      pps_last_unit_price &gt; '0'
      AND pps_last_unit_price != '' AND pps_product_id = ".$data['entity_id']."
      GROUP BY
      pps_product_id
  </code></pre>
  
  <p>and join with <code>SELECT *, COUNT(entity_id) AS conta FROM 
      ".Mage::getSingleton('core/resource')-&gt;getTableName('catalog_category_entity_varchar')." 
      WHERE attribute_id = 192 AND entity_id = ".$IDProduto." AND value != '' AND value != '0'</code>
  if is valid.
  Anybody can help me?
  Thanks</p>