How should I convert following sql statement into magento statement.
select value from customer_address_entity_varchar where attribute_id = 143 and entity_id = 567;
you can do that with below query
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$allrecord = $readconnection->select()->from(array('customer'=>'customer_address_entity_varchar'),array('customer.value'))->where('customer.attribute_id=?', 143)->where('customer.entity_id=?', 567);
$alldata =$readconnection->fetchOne($allrecord);
echo $alldata;
Try this:
echo "<pre>";
$result = array();
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$result = $read->fetchAll('select value from customer_address_entity_varchar where attribute_id = 143 and entity_id = 567');
print_r($result);