Hello,
I’m not exactly sure what you’re aiming to get. Are you looking to export the image data or the actual image files? You won’t be able to get the image files from the database as they’re stored on the server. Where they’re stored on the server is also stored in the database. In any case the below SQL should get you all the image attachments which are not featured images. I’m not sure if this is the most efficient way but it works:
SELECT
p.*
FROM
wp_posts AS p
WHERE
p.post_mime_type IN( 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'image/x-icon' ) AND
p.ID NOT IN(
SELECT
meta_value
FROM
wp_postmeta
WHERE
meta_key = '_thumbnail_id' AND
meta_value != ''
)
GROUP BY
p.ID