SQL
AخA
SET STATEMENT max_statement_time=100 FOR
SELECT page_title AS article, pl_title AS portal
FROM pagelinks
JOIN page ON page_id=pl_from AND page_namespace = 0
WHERE pl_namespace=100 AND pl_title NOT LIKE "%/%" AND pl_title NOT LIKE "%_(state)" /* Top level portal */
AND NOT EXISTS (SELECT 1 FROM page WHERE page_title=pl_title AND page_namespace=100) /* Portal is a redlink */
AND EXISTS (SELECT 1 FROM templatelinks WHERE tl_from=pl_from AND tl_title LIKE "Portal%") /* Article uses {{Portal...}} */
ORDER BY article, portal
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.