Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
This query is marked as a draft
This query has been published
by
維基小霸王
.
https://commons.wikimedia.org/wiki/Commons:Library_back_up_project
Toggle Highlighting
SQL
SET @basecat = 'Library_back_up_project'; SET max_recursive_iterations = 2; WITH RECURSIVE subcats (subcat, catpath, depth) AS ( SELECT cl_to AS subcat, REPLACE(cl_to, '_', ' ') AS catpath, 0 AS depth FROM categorylinks WHERE cl_from = (SELECT page_id FROM page WHERE page_title = @basecat AND page_namespace = 14) UNION SELECT cl.cl_to, CONCAT(sc.catpath, ' > ', REPLACE(cl.cl_to, '_', ' ')), sc.depth + 1 FROM categorylinks cl JOIN subcats sc ON cl.cl_from = sc.subcat JOIN page p ON cl.cl_from = p.page_id WHERE p.page_namespace = 14 ) SELECT DISTINCT subcat AS category, depth, catpath AS 'category path' FROM subcats ORDER BY depth, subcat;
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...