Double sql join query
Getting WordPress features images (_thumbnail_id) that have an empty caption and return the ID’s and there relative path (_wp_attachment_file).
SELECT POST.ID, POST.TITLE, POST.EXCERPT, META.VALUE FROM (SELECT p.ID AS ID, p.post_title AS TITLE, p.post_type, p.post_excerpt AS EXCERPT FROM wpka_posts AS p INNER JOIN wpka_postmeta AS pm ON pm.meta_value = p.ID AND pm.meta_key = '_thumbnail_id' AND p.post_parent != 0 AND p.post_type = 'attachment' AND p.post_excerpt = '' LIMIT 20) AS POST JOIN ( SELECT pa.meta_value AS VALUE, pa.meta_key, pa.post_id AS ID FROM wpka_postmeta AS pa WHERE pa.meta_key = '_wp_attached_file') AS META ON POST.ID = META.ID;