Magento execute custom query

How to magento execute custom query?In here you can execute custom query to insert,update,delete and fetch data from database with using magento existing database connection.

Magento execute custom query to insert data

Execute custom query to fetch data

Getting data into phtml files/view files



Execute custom query to update data