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
Chriswolfram
.
Toggle Highlighting
SQL
WITH RECURSIVE edges AS ( SELECT cl_from AS ref_child_id, page_id AS ref_parent_id FROM categorylinks INNER JOIN page ON cl_to=page_title AND page_namespace=14 ), edges_closed AS ( SELECT ref_child_id, ref_parent_id, 1 AS depth FROM edges WHERE ref_parent_id IN ( 3659008, -- Social_issues 62578579, -- Branches_of_science 697060, -- Applied_sciences 17503782, -- Formal_sciences 697022, -- Natural_sciences 695042 -- Social_sciences ) UNION SELECT edges.ref_child_id AS ref_child_id, edges_closed.ref_parent_id AS ref_parent_id, edges_closed.depth+1 AS depth FROM edges, edges_closed WHERE edges.ref_parent_id = edges_closed.ref_child_id AND depth < 5 ) SELECT ref_child_id, ref_parent_id, depth FROM edges_closed;
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...