SQL
AخA
SELECT P1.page_title AS article, 1 AS depth, CONCAT(CL1.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id AND CL1.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 2 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id AND CL2.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 3 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to, ", ", CL3.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id JOIN page P3 ON P3.page_title = CL2.cl_to AND P3.page_namespace=14
JOIN categorylinks CL3 ON CL3.cl_from=P3.page_id AND CL3.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 4 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to, ", ", CL3.cl_to, ", ", CL4.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id JOIN page P3 ON P3.page_title = CL2.cl_to AND P3.page_namespace=14
JOIN categorylinks CL3 ON CL3.cl_from=P3.page_id JOIN page P4 ON P4.page_title = CL3.cl_to AND P4.page_namespace=14
JOIN categorylinks CL4 ON CL4.cl_from=P4.page_id AND CL4.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 5 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to, ", ", CL3.cl_to, ", ", CL4.cl_to, ", ", CL5.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id JOIN page P3 ON P3.page_title = CL2.cl_to AND P3.page_namespace=14
JOIN categorylinks CL3 ON CL3.cl_from=P3.page_id JOIN page P4 ON P4.page_title = CL3.cl_to AND P4.page_namespace=14
JOIN categorylinks CL4 ON CL4.cl_from=P4.page_id JOIN page P5 ON P5.page_title = CL4.cl_to AND P5.page_namespace=14
JOIN categorylinks CL5 ON CL5.cl_from=P5.page_id AND CL5.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 6 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to, ", ", CL3.cl_to, ", ", CL4.cl_to, ", ", CL5.cl_to, ", ", CL6.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id JOIN page P3 ON P3.page_title = CL2.cl_to AND P3.page_namespace=14
JOIN categorylinks CL3 ON CL3.cl_from=P3.page_id JOIN page P4 ON P4.page_title = CL3.cl_to AND P4.page_namespace=14
JOIN categorylinks CL4 ON CL4.cl_from=P4.page_id JOIN page P5 ON P5.page_title = CL4.cl_to AND P5.page_namespace=14
JOIN categorylinks CL5 ON CL5.cl_from=P5.page_id JOIN page P6 ON P6.page_title = CL5.cl_to AND P6.page_namespace=14
JOIN categorylinks CL6 ON CL6.cl_from=P6.page_id AND CL6.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
UNION
SELECT P1.page_title AS article, 7 AS depth, CONCAT(CL1.cl_to, ", ", CL2.cl_to, ", ", CL3.cl_to, ", ", CL4.cl_to, ", ", CL5.cl_to, ", ", CL6.cl_to, ", ", CL7.cl_to) AS categories FROM page P1
JOIN categorylinks CL1 ON CL1.cl_from=P1.page_id JOIN page P2 ON P2.page_title = CL1.cl_to AND P2.page_namespace=14
JOIN categorylinks CL2 ON CL2.cl_from=P2.page_id JOIN page P3 ON P3.page_title = CL2.cl_to AND P3.page_namespace=14
JOIN categorylinks CL3 ON CL3.cl_from=P3.page_id JOIN page P4 ON P4.page_title = CL3.cl_to AND P4.page_namespace=14
JOIN categorylinks CL4 ON CL4.cl_from=P4.page_id JOIN page P5 ON P5.page_title = CL4.cl_to AND P5.page_namespace=14
JOIN categorylinks CL5 ON CL5.cl_from=P5.page_id JOIN page P6 ON P6.page_title = CL5.cl_to AND P6.page_namespace=14
JOIN categorylinks CL6 ON CL6.cl_from=P6.page_id JOIN page P7 ON P7.page_title = CL6.cl_to AND P6.page_namespace=14
JOIN categorylinks CL7 ON CL7.cl_from=P7.page_id AND CL7.cl_to="Mathematics"
WHERE P1.page_namespace=0 AND P1.page_title="English"
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.