Magento Certified Developer GuideCategory: 4. DatabaseDescribe the role of Zend_Db_Select in Magento
Manish Prakash Staff asked 3 years ago

This class is used by magento for all its select queries on flat tables. This class has functions for all the select operations which we perform on a table. Below the important functions are described.

        $db = Mage::getModel('core/resource')->getConnection('core_read');
        $select = $db->select();
        $select->from(array('c' => 'core_resource'))->where('id = ?', 1);
        $select->orWhere('code = ?', 'adminnotification_setup');
        $select->order(array(Zend_Db_Select::SQL_DESC => 'version'));
        $select->limit(10, 20);
        $select->distinct();
        $select->columns(array('code', 'version'));
        $select->joinLeft(array('e' => 'core_config_data'), 'e.id = c.version');
//        $select->query();  //execute the query
//$select->union()
//joinLeft,joinFull,joinNatural,joinCross,joinRight,joinInner
//$select->having()
//$select->orHaving()
//$select->reset()
        echo $select;

Different type of joins are explain here
http://stackoverflow.com/a/6294854
http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-cross-join.php
http://www.w3resource.com/mysql/advance-query-in-mysql/mysql-natural-join.php