SQL
x
SET @c = 'American_screenwriters';
SELECT
pg1.page_title,
subs.cl_to
FROM
page AS pg1
JOIN categorylinks AS cl1 ON cl1.cl_from = pg1.page_id
JOIN (
SELECT
cl2.cl_from,
cl2.cl_to
FROM
categorylinks AS cl2
WHERE
cl2.cl_to IN (
SELECT
page_title
FROM
page pg3
JOIN categorylinks AS cl3 ON pg3.page_id = cl3.cl_from
WHERE
cl3.cl_to = @c
AND cl3.cl_type = 'subcat'
)
) AS subs ON subs.cl_from = cl1.cl_from
WHERE
cl1.cl_to = @c
AND cl1.cl_type = 'page'
AND page_namespace = 0
LIMIT 1;
SELECT * FROM categorylinks cl2
WHERE cl2.cl_to IN (
SELECT pg3.page_title
FROM page pg3
JOIN categorylinks cl3 ON cl3.cl_from = pg3.page_id
WHERE cl_to = @c
AND cl_type = 'subcat'
)
LIMIT 100;
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.