magento 2 order get product id code example
Example: magento 2 find orders for a product
SELECT so.customer_email, soi.sku, soi.name FROM `sales_order` as so left join sales_order_item as soi on so.entity_id = soi.order_id where soi.sku = 'your_product_sku'