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
Aram
.
Toggle Highlighting
SQL
-- Sample Quarry Query to Extract Usernames from Wikitext USE ckbwiki_p; -- Replace 'بەکارھێنەر:Aram/تاقیکردنەوە' with the desired page title -- Make sure the page title is properly URL-encoded if necessary -- For example, spaces should be replaced with underscores SET @pageTitle = 'بەکارھێنەر:Aram/تاقیکردنەوە'; -- Retrieve the wikitext of the specified page SELECT rev_text FROM revision WHERE rev_page = (SELECT page_id FROM page WHERE page_title = @pageTitle) ORDER BY rev_timestamp DESC LIMIT 1; -- Extract usernames from the wikitext using a regular expression -- This query assumes that usernames are enclosed in double square brackets WITH page_wikitext AS ( SELECT rev_text FROM revision WHERE rev_page = (SELECT page_id FROM page WHERE page_title = @pageTitle) ORDER BY rev_timestamp DESC LIMIT 1 ) SELECT DISTINCT REGEXP_REPLACE( -- Regular expression to match usernames in double square brackets REGEXP_CAPTURE(page_wikitext.rev_text, r'\[\[User:([^|\]]+)(?:\|[^|\]]+)?\]\]'), -- Capture group containing the username r'\[\[User:([^|\]]+)(?:\|[^|\]]+)?\]\]', '\\1' ) AS username FROM page_wikitext WHERE page_wikitext.rev_text LIKE '%[[User:%'; -- This query retrieves and lists the extracted usernames
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...