SQL
AخA
USE enwiki_p;
SELECT p.page_id FROM page p
INNER JOIN image i ON p.page_title = i.img_name
LEFT JOIN categorylinks c ON p.page_id = c.cl_from AND c.cl_to IN ('All_non-free_media', 'All_free_media', 'All_free_in_US_media')
WHERE p.page_namespace = 6
AND c.cl_from IS NULL
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.