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
# SELECT DISTINCT pl_from 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 = ''); SELECT COUNT(DISTINCT pl_from) AS 'either (unique)', COUNT(indirect) AS 'indirect (unique)', COUNT(direct) AS 'direct' 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`; SELECT COUNT(pl_from) AS 'direct + indirect (unique)', COUNT(indirect) AS 'indirect (unique)', COUNT(pl_from) - COUNT(indirect) 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 SELECT pl_from, NULL AS indirect FROM pagelinks WHERE pl_title = 'Toronto' AND pl_namespace = 0 ) AS `temp`; SELECT COUNT(pl_from) AS 'direct + indirect', COUNT(indirect) AS 'indirect', COUNT(pl_from) - COUNT(indirect) 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...