SQL
AخA
USE commonswiki_p;
SELECT page_id, page_title, cl_to, CONCAT("Q", interior_ips.ips_item_id), CONCAT("Q", parent_ips.ips_item_id)
FROM page
LEFT JOIN wikidatawiki_p.wb_items_per_site AS interior_ips
ON interior_ips.ips_site_page=CONCAT("Category:", REPLACE(page_title, "_", " "))
AND interior_ips.ips_site_id="commonswiki"
LEFT JOIN wikidatawiki_p.wb_items_per_site AS parent_ips
ON parent_ips.ips_site_page=CONCAT("Category:", REPLACE(page_title, "_", " "))
AND parent_ips.ips_site_id="commonswiki"
LEFT JOIN categorylinks
ON cl_from=page_id
AND cl_to=REGEXP_REPLACE(page_title, "Interior_of_(the)?", "")
WHERE
page.page_namespace=14 AND
page.page_title LIKE "Interior_of_%";
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.