Database join with group
Posted on November 28, 2019, 1:11 pm, by admin, under
Magento 1.x.
$limit = 1000;
$d_collection = Mage::getResourceModel('modulename/tablename_collection')
->addFieldToFilter('main_table_field', true)
->setOrder('entity_id', 'asc')
->setPageSize($limit);
$d_collection->getSelect()->join( array('tablename'=> Mage::getSingleton('core/resource')->getTableName('modulename/tablename')),
'tablename.entity_id = main_table.entity_id',
array());
$d_collection->addFieldToFilter('tablename.table_field', 0);
$d_collection->getSelect()->group('main_table.entity_id');
$d_collection->addFieldToSelect('entity_id'); |