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
Gone Postal
.
Toggle Highlighting
SQL
WITH RECURSIVE `needed_category` AS ( SELECT `cat_title` AS `name` FROM `category` WHERE (`cat_pages` > 0 OR `cat_subcats` > 0 OR `cat_files` > 0) AND `cat_title` NOT IN (SELECT `page_title` FROM `page`) ), `known_countries_cat` AS ( SELECT `page_title` AS `name` FROM `page` INNER JOIN `categorylinks` ON `page`.`page_id`=`categorylinks`.`cl_from` WHERE `categorylinks`.`cl_to` IN('Countries_by_name', 'Former_countries_by_name') AND `page`.`page_namespace`=14 ), `known_countries` AS ( SELECT `name` FROM `known_countries_cat` UNION SELECT CONCAT('The_', `name`) FROM `known_countries_cat` ), `month_seq` AS ( SELECT 'January' AS `m` UNION SELECT 'February' UNION SELECT 'March' UNION SELECT 'April' UNION SELECT 'May' UNION SELECT 'June' UNION SELECT 'July' UNION SELECT 'August' UNION SELECT 'September' UNION SELECT 'October' UNION SELECT 'November' UNION SELECT 'December' ), `year_seq` AS ( SELECT 1800 AS `y` UNION ALL SELECT `y` + 1 FROM `year_seq` WHERE `y` < YEAR(NOW()) ), `decade_seq` AS ( SELECT DISTINCT `y` DIV 10 AS `d` FROM `year_seq` ), `century_seq` AS ( SELECT '19th' AS `c` UNION SELECT '20th' AS `c` UNION SELECT '21st' AS `c` ), `possible_category` AS ( SELECT CONCAT(`month_seq`.`m`, '_', `year_seq`.`y`, '_', `known_countries`.`name`, '_photographs') AS `name`, `known_countries`.`name` AS `country` FROM `month_seq`, `year_seq`, `known_countries` UNION SELECT CONCAT(`year_seq`.`y`, '_photographs_of_', `known_countries`.`name`) AS `name`, `known_countries`.`name` AS `country` FROM `year_seq`, `known_countries` UNION SELECT CONCAT(`decade_seq`.`d`, '0s_photographs_of_', `known_countries`.`name`) AS `name`, `known_countries`.`name` AS `country` FROM `decade_seq`, `known_countries` UNION SELECT CONCAT(`century_seq`.`c`, '-century_photographs_of_', `known_countries`.`name`) AS `name`, `known_countries`.`name` AS `country` FROM `century_seq`, `known_countries` ) SELECT CONCAT('[[:Category:', `needed_category`.`name`, ']]') as `link` FROM `needed_category` INNER JOIN `possible_category` ON `needed_category`.`name`=`possible_category`.`name` ORDER BY `possible_category`.`country`;
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...