Take a look at http://magento.stackexchange.com/questions/19863/how-to-convert-sql-query-to-magento-in-order-to-fetch-data $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $readresult = $read->query("SELECT id FROM customers_old"); while ($row = $readresult->fetch() ) { $Ids[] = $row['id']; }