SQL
AخA
USE enwiki_p;
SELECT p.page_title FROM page p
INNER JOIN categorylinks c1 ON c1.cl_from = p.page_id AND c1.cl_to = 'All_free_media'
INNER JOIN categorylinks c2 ON c2.cl_from = p.page_id AND c2.cl_to = 'All_non-free_media'
#INNER JOIN categorylinks c ON c.cl_from = p.page_id AND c.cl_to IN ('All_free_media', 'All_non-free_media')
LEFT JOIN templatelinks t ON t.tl_from = p.page_id AND t.tl_namespace = 10 AND t.tl_title = 'Photo_of_art'
WHERE t.tl_from IS NULL
#GROUP BY p.page_id
#HAVING COUNT(*) = 2
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.