Fork of Untitled query #5979 by Sfan00 IMG
This query is marked as a draft This query has been published by ShakespeareFan00.

SQL

AخA
 
USE enwiki_p;
SELECT p.page_id,CONCAT("File:",p.page_title) FROM page p
INNER JOIN categorylinks c1 ON p.page_id = c1.cl_from
LEFT JOIN imagelinks i ON p.page_title = i.il_to AND ((i.il_from_namespace = 0) OR (i.il_from_namespace = 118))
LEFT JOIN categorylinks c2 ON p.page_id = c2.cl_from AND c2.cl_to = "All_orphaned_non-free_use_Wikipedia_files"
LEFT JOIN templatelinks t ON t.tl_from = p.page_id
                          AND t.tl_namespace = 10
                          AND t.tl_title IN (
                            'Ffd', 
                            'Puf', 
                            'Di-orphaned_fair_use',
                            'Di-replaceable fair_use',
                            'Deletable_file', 
                            'Db-meta', 
                            'Now_Commons', 
                            'NFUR_not_needed', 
                            'Wrong-license',
                            'duplicate')
WHERE c1.cl_to = "All_non-free_media"
AND i.il_from IS NULL
AND c2.cl_from IS NULL
AND t.tl_from IS NULL
AND p.page_namespace = 6
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.

Checking query status...