Wikipedia:Request a query#ReferenceExpander
{{Short description|Page for requesting database queries}}
__NEWSECTIONLINK__
{{User:MiszaBot/config
| algo = old(14d)
| archive = Wikipedia:Request a query/Archive %(counter)d
| counter = 5
| maxarchivesize = 150K
| archiveheader = {{Automatic archive navigator}}
| minthreadstoarchive = 1
| minthreadsleft = 4
}}
{{Archives|age=14|units=days}}
{{shortcut|WP:RAQ|WP:QUARRY|WP:SQLREQ|WP: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 [https://petscan.wmflabs.org 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.
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. {{Fake link|User:Example/Userboxes}} and {{Fake link|User:Example/Userboxen}}, but not an individual userbox subpage, such as {{Fake link|User: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)
:The first and third are easy enough. For the second, how do you propose to distinguish between galleries and single-userbox subpages like {{fake link|User:Example/My awesome userbox}}? (Or is it enough to include pages with no more than one slash?) —Cryptic 03:30, 23 April 2025 (UTC)
::Cryptic, by the full name of the subpage. [https://en.wikipedia.org/w/index.php?search=intitle%3A%22%2FUserboxes%22&title=Special%3ASearch&profile=advanced&fulltext=1&ns2=1 "Userboxes"] and [https://en.wikipedia.org/w/index.php?search=intitle%3A%22%2FUserboxen%22&title=Special%3ASearch&profile=advanced&fulltext=1&ns2=1 "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/{{green|Userboxes}}
and User:Example/{{green|Userboxen}}
are OK, but User:Example/{{red|Userboxes}}/subpage
and User:Example/{{red|Any other subpage name}}
are not. —andrybak (talk) 14:33, 23 April 2025 (UTC)
:::quarry:query/93083. —Cryptic 21:33, 23 April 2025 (UTC)
::::Thank you so much!
::::For the record, the categorization issues have been cleaned up in [https://en.wikipedia.org/w/index.php?title=Special%3AContributions%2FAndrybak&target=Andrybak&offset=20250423231225001&limit=67 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)
Number of thanks received
{{u|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). [https://en.wikipedia.org/wiki/Special:Log?type=thanks&user=&page=User%3ABD2412&wpdate=&tagfilter=&wpFormIdentifier=logeventslist 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)
: 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 {{pval|1=&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)
::quarry:query/93358, and no. —Cryptic 23:09, 5 May 2025 (UTC)
::: {{resolved}} Thanks very much, {{u|Cryptic}}! Mathglot (talk) 23:16, 5 May 2025 (UTC)
:@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):
:
KStoller-WMF (talk) 21:15, 5 May 2025 (UTC){{Special:Impact/Username}}
:: {{u|KStoller-WMF}}, thanks. I subscribed to the phab task, and if you maintain a separate ping list for future enhancements or tasks, please add me. Mathglot (talk) 23:16, 5 May 2025 (UTC)
list of articles with templates of copy edit or peacock and no edits in last month
deepseek ai has brought me to quarry and i stumbled across this page link ;). i am trying to reduce reliance on mobile browsers, particularly after localhost mess. i am new and trying to learn at snails pace. can you please provide querys 1. all articles with templates: copy edit or peacock AND exclude articles edited after 15th may, 2025. 2. all articles with template: copy edit. Kiji-Jiki (talk) 08:58, 15 June 2025 (UTC)
:2 is essentially :Category:All Wikipedia articles needing copy edit, since {{tnull|Copy edit}} adds that category automatically to pages that it's used on. For 1, try this PetScan query. J11csd (talk) 22:44, 15 June 2025 (UTC)
::@J11csd anticipated huge numbers. list is not that much big, it will keep me busy. thanks. Kiji-Jiki (talk) 00:06, 16 June 2025 (UTC)
Quarry: Subcategories of Depth 3
Hi there,
I am not sure if this is the right place to post this question, but I am in need of support so any advice will be appreciated.
Essentially, I am trying to get a list of subcategories (containing articles i.e. non-empty subcategories) from the parent category "Catégorie:Personnalité_féminine" on the French Wikipedia on depth level 3.
I know that I would need to loop through subcategories to get the subcategories below. This is what I have so far. It is an adaptation from an already existing query. It clearly does not output the subcategories, so I am hoping someone can help me here. MNSanchez (talk) 00:02, 17 June 2025 (UTC)
: WP:PetScan may be a better tool for what you are trying to do. * Pppery * it has begun... 00:03, 17 June 2025 (UTC)
::Petscan can get a list of the subcats in that tree, though I don't think it can limit it to ones with at least one article in them.{{pb}}The WITH clause constructs a table (not really, but it can be used like one) named "deepcat" with a single column "subcat" that lists all the categories in that tree to the specified depth, with duplicates removed. So far so good. What you did after, though, wasn't to look at that table at all, but directly at the categorylinks table. Everything from the categorylinks table. Every category that every page is in, including duplicates. On enwiki, that's about 200 million rows, which is A) why the query wouldn't complete, and B) why Quarry would've broken even if the underlying query did complete - it can't really deal with resultsets larger than about 100 thousand rows.{{pb}}If you just wanted the list of those subcats, replace the last line in your fork with "SELECT subcat FROM deepcat;
". It'll complete instantly and give you 218 results. For ones containing any page (and subcats of their own qualify as pages in this sense), replace it with "SELECT DISTINCT subcat FROM deepcat JOIN categorylinks ON cl_to = subcat;
". If you specifically mean "articles" the way we use it on enwiki, you've also got to check that they're in namespace 0, not a redirect, and not a disambig; you can do that by joining page (for page_namespace and page_is_redirect) for the first two, and joining page_props for the third. —Cryptic 01:28, 17 June 2025 (UTC)