Fork of Articles linked from September 15 by Coffeeandcrumbs
This query is marked as a draft This query has been published by Coffeeandcrumbs.

SQL

AخA
 
SELECT
  page_title #Faster than just selecting the page title and id, but only those are needed
FROM
  page pg1
WHERE
  pg1.page_namespace = 0 #Only care about articles
  AND pg1.page_title IN ( #Where page is linked from a specified other page
    SELECT
      pl_title
    FROM
      pagelinks
    WHERE
      pl_from = 27650 #September 16
      AND pl_namespace = 0 #Only if the target is an article
  )
  AND  ( #AND the page is linked from a specified other page and the talk page is in a different set of specified categories
    (
        pg1.page_title NOT IN ( #Where page is not linked from a different specified other page
            SELECT
                pl_title
            FROM
                pagelinks
            WHERE
                pl_from = 492862 #Wikipedia:Selected anniversaries/September 16
            AND pl_namespace = 0 #Only if the target is an article
        )
    )
  AND ( #Talk page is in specified categories
      pg1.page_title IN ( #Match article's title to talk page (corresponding talk page's page ID needed for categorylinks lookup)
        SELECT
          page_title
        FROM
          page pg2
        WHERE
          pg1.page_title = pg2.page_title #Same title
          AND page_namespace = 1 #Page is a talk page
          AND page_id IN ( #Talk page is in categories
            SELECT
              cl_from
            FROM
              categorylinks
            WHERE
              cl_to IN (
                "All_WikiProject_Women-related_pages",
                "WikiProject_Women's_History_articles"
              ) #Categories specified for the talk page
          )
      )
    )
  )
  AND ( #AND either the page is in specified categories or the talk page is in a different set of specified categories
    (
      pg1.page_id NOT IN ( #Page is not in specified categories
        SELECT
          cl_from
        FROM
          categorylinks
        WHERE
          cl_to IN ("Good_articles", "Featured_articles") #Categories specified for the article
      )
    )
    OR ( #Talk page is in specified categories
      pg1.page_title NOT IN ( #Match article's title to talk page (corresponding talk page's page ID needed for categorylinks lookup)
        SELECT
          page_title
        FROM
          page pg2
        WHERE
          pg1.page_title = pg2.page_title #Same title
          AND page_namespace = 1 #Page is a talk page
          AND page_id IN ( #Talk page is in categories
            SELECT
              cl_from
            FROM
              categorylinks
            WHERE
              cl_to IN (
                "Wikipedia_featured_article_candidates",
                "Wikipedia_former_featured_articles",
                "Wikipedia_featured_article_review_candidates",
                "Good_article_nominees",
                "Featured articles that have appeared on the main page",
                "Featured articles that have not appeared on the main page"
              ) #Categories specified for the talk page
          )
      )
    )
  )
#LIMIT 10
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...