Last active
November 19, 2018 03:10
-
-
Save locvfx/b3faf3cac6d894c7fd345cc694ea3f1c to your computer and use it in GitHub Desktop.
SQLl to select random record in huge data table #SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT `post_title` FROM bf_article_posts AS r1 JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM bf_article_posts)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 10 | |
| #https://stackoverflow.com/questions/4329396/mysql-select-10-random-rows-from-600k-rows-fast | |
| #http://jan.kneschke.de/projects/mysql/order-by-rand/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment