How to run custom MySql query in Magento2 and fetch data?
<?php
//Connection with magento2 database
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection('core_read');
//Now execute your mysql query
$fetch="SELECT * FROM catalog_product_entity";
$result = $connection->fetchAll($fetch);
?>