As we know that there are various method through which we can display featured image in frontend but sometime we need to add some contents or add blog on another site then at that time there does not work wordpress query neither wordpress functions. so that we use mysql query to display wordpress blog data on another site. But at that time we need to fetch featured image become little typical so I have mentioned below sql query trough which you can show thumbnail image.
Below is the sql query to display thumbnail image:
SELECT p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN
wp_postmeta wm1 ON (
wm1.post_id = p1.id
AND wm1.meta_value IS NOT NULL
AND wm1.meta_key = "_thumbnail_id"
LEFT JOIN wp_postmeta wm2 ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = "_wp_attached_file"
AND wm2.meta_value IS NOT NULL) WHERE p1.post_status="publish" AND p1.post_type="post"
ORDER BY p1.post_date DESC
In this query you don’t need to pass any post id or others things but as per your requirement you can customized the query.
Cheers, Enjoy the code.