How to run Custom Query in Magento ?

Check out the below code.

$db = Mage::getSingleton('core/resource')->getConnection('core_write');

$result = $db->query('SELECT * FROM users where id=4');