Wikipedia:Request a query

This is a page for requesting one-off database queries for certain criteria. Users who are interested and able to perform SQL queries on the projects can provide results from the Quarry website.

You may also be interested in the following:

  • If you are interested in writing SQL queries or helping out here, visit our tips page.
  • If you need to obtain a list of pages that meet certain criteria, consider using PetScan (user manual) or the default search. PetScan can generate lists of articles in subcategories, articles which transclude some template, etc.
  • If you need to make changes to a number of articles based on a particular query, you can post to the bot requests page, depending on how many changes are needed.
  • For long-term review and checking, database reports are available.

The database replicas do not have access to page content, so queries which require checking wikitext cannot be answered with database queries. In particular, there is no way to query for template parameters or anything related to references. However, someone may be able to assist by querying in another way (for example, checking for external links rather than references) or suggest an alternative tool.

Unusually large redirect talk archives

I recently found out that when pages and their archives are moved but archive template is not updated, ClueBot III keeps adding talk sections below the old location of archive (which is now a redirect). See Special:History/Talk:2024 Kolkata rape and murder incident/Archive 1. I need a list of talk archives that are redirects but are also unusually large (>250 bytes), ordered by page size in descending order. Thanks! CX Zoom[he/him] (let's talk • {CX}) 16:15, 2 April 2025 (UTC)[reply]

quarry:query/92487. —Cryptic 17:41, 2 April 2025 (UTC)[reply]
And quarry:query/92489 has a version that limits it to pages with at least one edit by one of the accounts in Category:Wikipedia archive bots. —Cryptic 18:02, 2 April 2025 (UTC)[reply]
...though I should've foreseen that one-click-archiver would've made that idea unhelpful. (Special:History/Talk:2020 Nagorno-Karabakh conflict/Archive 13, for example.) quarry:query/92490 instead looks for at least one edit with a summary containing "rchiv" and that wasn't made by User:AnomieBOT or User:Xqbot. —Cryptic 18:15, 2 April 2025 (UTC)[reply]
Thank you very much! CX Zoom[he/him] (let's talk • {CX}) 19:15, 2 April 2025 (UTC)[reply]

Articles with a particular template missing a data element from that template

How would I create query that finds all articles with a template (e.g. "Infobox university") that are missing a particular data element in that template (e.g. "logo")? A couple scenarios I'm thinking of:

  • University articles missing the school logo
  • Album articles missing cover art
  • Musician articles missing image of person

TIA - hope this isn't too much of a newb question for this request page! — Preceding unsigned comment added by Widgetkid (talkcontribs) 16:48, 2 April 2025 (UTC)[reply]

In practical terms, you can't - template parameters aren't exposed to the database except as part of the wikitext, so you'd have to parse that yourself; and the text isn't copied to the database replicas, so you'd have to download a dump to do even that. Or grab the pages' text from the API, if you can narrow the set enough - Special:Whatlinkshere/Template:Infobox university has close to 27000 pages on it, which is about two orders of magnitude too many for that approach to work well. (Top of this page:Quarry does not have access to page content, so queries which require checking wikitext cannot be answered with database queries. In particular, there is no way to query for template parameters or anything related to references.) The usual solution is to change the template to add a tracking category. —Cryptic 17:51, 2 April 2025 (UTC)[reply]
Thanks @Cryptic! Can you tell me more about how the solution with adding a tracking category would work (or point me to an example)? I'm good with rolling up my sleeves to find a way to do this. 😀  ⚙️ WidgetKid 🙈🙉🙊  19:37, 2 April 2025 (UTC)[reply]
{{Infobox university}} in particular actually already does this - search its source for "Category:Pages using infobox university with the image name parameter". —Cryptic 19:40, 2 April 2025 (UTC)[reply]

User pages categorized as a user template

A common mistake by editors is to copy-paste the whole wikitext of a user template onto their user page, which causes the user page to be incorrectly categorized as a template. These categories have "user templates" in their name (e.g. Category:WikiProject user templates).

I would like to have a query that finds the following user pages which are categorized into any category with "user templates" in their name:

  • top-level user pages – not subpages, i.e. no slashes in the page's title, User:Example and User:Sample user
  • subpages which are a user's userbox gallery, e.g.User:Example/Userboxes andUser:Example/Userboxen, but not an individual userbox subpage, such asUser:Example/Userboxes/My awesome userbox
  • user talk pages – both top-level and subpages (often, such categorization wikitext gets archived from discussions), e.g. User talk:Example and User talk:Example/Archives/2012/December

Thanks. —⁠andrybak (talk) 14:21, 19 April 2025 (UTC)[reply]

The first and third are easy enough. For the second, how do you propose to distinguish between galleries and single-userbox subpages likeUser:Example/My awesome userbox? (Or is it enough to include pages with no more than one slash?) —Cryptic 03:30, 23 April 2025 (UTC)[reply]
Cryptic, by the full name of the subpage. "Userboxes" and "Userboxen" are the most popular variants. For such cases "Userboxes" must be the last component in the page title (by "components" I mean substrings separated by forward slashes). User:Example/subpages/Userboxes and User:Example/Userboxen are OK, but User:Example/Userboxes/subpage and User:Example/Any other subpage name are not. —⁠andrybak (talk) 14:33, 23 April 2025 (UTC)[reply]
quarry:query/93083. —Cryptic 21:33, 23 April 2025 (UTC)[reply]
Thank you so much!
For the record, the categorization issues have been cleaned up in these ~67 edits. Only three userboxes are left in the result, all three are regular userboxes, not galleries, which just happened to have a name ending in "/Userboxes". —⁠andrybak (talk) 23:30, 23 April 2025 (UTC)[reply]

Number of thanks received

BD2412 asked at VPT about creating a userbox with the number of thanks they received. This quarry request is maybe a start in that direction (though not a full solution). This log link lists the first 50 of them; can we get a query which will return an integer reporting the number of thanks? And, um, thanks! Mathglot (talk) 20:10, 5 May 2025 (UTC)[reply]

Kind of a corollary question: assuming this query works out and generates a result for User:BD2412, I know how to link to a quarry query, but is there a way to pass an identifier using a query string parameter in the url? I.e., so that we would add &user=Mathglot into the url with the same Quarry id, so that it would run the same query except passing my userid instead of theirs? Or do I have to clone the query and hard-code my userid? Thanks, Mathglot (talk) 21:07, 5 May 2025 (UTC)[reply]
@Mathglot - This might not be exactly what you’re looking for, but there is a Thanks count available via Special:Impact. Currently, that number is capped at 1,000, so experienced editors like you may see “999+” instead of the exact count.
That said, we’re actively working on raising that cap to 10,000 as part of this task: T341599 Impact Module: improvements for former newcomers
So hopefully, you’ll be able to see your Thanks total on Special:Impact (or via Special:Homepage) soon. This doesn’t entirely solve your original request, but in the meantime, you can transclude your Impact module on your user page with the following code (just replace Username with your actual username):
{{Special:Impact/Username}}
KStoller-WMF (talk) 21:15, 5 May 2025 (UTC)[reply]
Uses material from the Wikipedia article Wikipedia:Request a query, released under the CC BY-SA 4.0 license.