Fork of subcat cats with cats & no WD items by Jheald
This query is marked as a draft This query has been published by Jheald.

SQL

x
 
use enwiki_p;
#SELECT pp.pp_value, p3.page_title, GROUP_CONCAT(c_up.cl_to SEPARATOR ' / ') AS cats 
SELECT p.page_title, pp.pp_value, p1.page_title, GROUP_CONCAT(DISTINCT(c_up.cl_to) SEPARATOR ' / ') AS cats 
FROM categorylinks AS c1                   ##
JOIN page AS p1 ON c1.cl_from=p1.page_id AND p1.page_namespace=14 AND p1.page_is_redirect=0
JOIN categorylinks AS c ON c.cl_to = p1.page_title
JOIN page AS p ON c.cl_from=p.page_id AND p.page_namespace=14 AND p.page_is_redirect=0
JOIN categorylinks AS c_up ON c_up.cl_from=p.page_id
LEFT JOIN page_props AS pp ON pp.pp_page = p.page_id AND pp.pp_propname = 'wikibase_item'
#JOIN page_props AS pp ON pp.pp_page = p3.page_id AND pp.pp_propname = 'wikibase_item'
WHERE c1.cl_to='Populated_places_in_Scotland_by_council_area'
GROUP BY p.page_title;
#LIMIT 500;
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.

Checking query status...