Split single table field to two separate fields in Magento collection

Here is the example of split order street address in to 2 separate fields separated by ‘n’ newline.

<?php
$collection = Mage::getModel('sales/order_address')->getCollection()
            ->addExpressionFieldToSelect('street_line1',
                    'IF(LOCATE("n", {{full_street}}) > 0,
                        SUBSTRING({{full_street}}, 1, LOCATE("n", {{full_street}}) - 1),
                        {{full_street}} )',
                array('full_street' => 'street'))

            ->addExpressionFieldToSelect('street_line2',
                    'IF(LOCATE("n", {{full_street}}) > 0,
                        SUBSTRING({{full_street}}, LOCATE("n", {{full_street}}) + 1),
                        NULL )',
                array('full_street' => 'street'));            
print_r($collection->getData());        
?>

On print_r($collection->getData()); you can see the 2 new field added to result ‘street_line1′ and ‘street_line2′.

Note : Use ‘addExpressionAttributeToSelect’ if not works ‘addExpressionFieldToSelect’.