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
BrandonXLF
.
Toggle Highlighting
SQL
# redirect SELECT DISTINCT COUNT(rd_from) FROM redirect WHERE rd_title = 'Toronto' AND rd_namespace = 0 AND (rd_interwiki IS NULL OR rd_interwiki = ''); # pagelinks, categorylinks SELECT COUNT(DISTINCT pl_from) - 43, COUNT(indirect), COUNT(direct) - 43 FROM ( SELECT pl_from, 1 AS indirect, NULL AS direct FROM redirect JOIN page AS target ON target.page_id = rd_from JOIN pagelinks ON pl_title = target.page_title AND pl_namespace = target.page_namespace WHERE rd_namespace = 0 AND rd_title = 'Toronto' AND (rd_interwiki IS NULL OR rd_interwiki = '') UNION ALL SELECT pl_from, NULL AS indirect, 1 AS direct FROM pagelinks WHERE pl_title = 'Toronto' AND pl_namespace = 0 ) AS temp; # templatelinks, imagelinks SELECT COUNT(DISTINCT fromid), COUNT(indirect), COUNT(DISTINCT fromid) - COUNT(indirect) FROM ( SELECT t1.tl_from AS fromid, 1 AS indirect, NULL AS direct FROM redirect JOIN page AS target ON target.page_id = rd_from JOIN templatelinks AS t1 ON t1.tl_title = target.page_title AND t1.tl_namespace = target.page_namespace # Only include links that actually transclude the redirect target JOIN templatelinks AS t2 ON t2.tl_from = t1.tl_from AND t2.tl_title = 'WikiProject_Canada_Streets' AND t2.tl_namespace = 10 WHERE rd_namespace = 10 AND rd_title = 'WikiProject_Canada_Streets' AND (rd_interwiki IS NULL OR rd_interwiki = '') UNION ALL SELECT tl_from AS fromid, NULL AS indirect, 1 AS direct FROM templatelinks WHERE tl_title = 'WikiProject_Canada_Streets' AND tl_namespace = 10 ) AS temp; # templatelinks, imagelinks SELECT COUNT(DISTINCT direct), COUNT(DISTINCT tl_from), COUNT(DISTINCT direct) - COUNT(DISTINCT tl_from) FROM redirect JOIN page AS target ON target.page_id = rd_from JOIN templatelinks ON tl_title = target.page_title AND tl_namespace = target.page_namespace RIGHT JOIN ( SELECT tl_from AS direct FROM templatelinks WHERE tl_title = 'WikiProject_Canada_Streets' AND tl_namespace = 10 ) AS temp ON tl_from = direct AND rd_namespace = 10 AND rd_title = 'WikiProject_Canada_Streets' AND (rd_interwiki IS NULL OR rd_interwiki = ''); # templatelinks, imagelinks SELECT COUNT(DISTINCT tl_from), COUNT(DISTINCT indirect), COUNT(DISTINCT tl_from) - COUNT(DISTINCT indirect) FROM templatelinks SELECT tl_from AS direct FROM templatelinks LEFT JOIN ( SELECT tl_from AS indirect FROM redirect JOIN page AS target ON target.page_id = rd_from JOIN templatelinks ON tl_title = target.page_title AND tl_namespace = target.page_namespace WHERE rd_title = 'WikiProject_Canada_Streets' AND (rd_interwiki IS NULL OR rd_interwiki = '') ) AS temp ON tl_from = indirect AND tl_title = 'WikiProject_Canada_Streets' AND tl_namespace = 10; # current SELECT COUNT(pl_from) - 43 AS 'direct + indirect', COUNT(indirect) AS 'indirect', COUNT(pl_from) - COUNT(indirect) - 43 AS 'direct' FROM ( SELECT pl_from, 1 AS indirect FROM redirect JOIN page AS target ON target.page_id = rd_from JOIN pagelinks ON pl_title = target.page_title AND pl_namespace = target.page_namespace WHERE rd_namespace = 0 AND rd_title = 'Toronto' AND (rd_interwiki IS NULL OR rd_interwiki = '') UNION ALL SELECT pl_from, NULL AS indirect FROM pagelinks WHERE pl_title = 'Toronto' AND pl_namespace = 0 ) AS temp;
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...