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
Jdcc-berkman
.
Toggle Highlighting
SQL
# http://jan.kneschke.de/projects/mysql/order-by-rand/ # https://stackoverflow.com/questions/249301/simple-random-samples-from-a-sql-database # https://mariadb.com/kb/en/library/data-sampling-techniques-for-efficiently-finding-a-random-row/#case-consecutive-auto_increment-without-gaps-10-rows ### All non-deleted revisions in the article namespace #SELECT revision.rev_id, page.* FROM revision #JOIN page on revision.rev_page = page.page_id #JOIN (SELECT CEIL(RAND() * (SELECT MAX(rev_id) FROM revision)) AS rev_id) AS random #WHERE revision.rev_id = random.rev_id #AND rev_deleted = 0 AND page_namespace = 0; -- more than 10 (to compensate for dups) SELECT @min := MIN(rev_id), @max := MAX(rev_id) FROM revision; SELECT DISTINCT revision.rev_id, page.* FROM revision JOIN page on revision.rev_page = page.page_id JOIN (SELECT FLOOR(@min + (@max - @min + 1) * RAND()) AS rev_id FROM revision LIMIT 11) AS random USING (rev_id) WHERE rev_deleted = 0 AND page_namespace = 0 LIMIT 10; ### All non-deleted revisions in the article-talk namespace #SELECT * FROM revision JOIN page on revision.page_id = page.page_id WHERE rev_deleted = 0 AND page_namespace = 1 ORDER BY RAND() LIMIT 10000; ### All non-deleted revisions in the user namespace #SELECT * FROM revision JOIN page on revision.page_id = page.page_id WHERE rev_deleted = 0 AND page_namespace = 2 ORDER BY RAND() LIMIT 10000; ### All non-deleted revisions in the user-talk namespace #SELECT * FROM revision JOIN page on revision.page_id = page.page_id WHERE rev_deleted = 0 AND page_namespace = 3 ORDER BY RAND() LIMIT 10000;
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...