Created
January 18, 2015 18:25
-
-
Save dennisdegryse/c24a78a21b3b81f1f3e6 to your computer and use it in GitHub Desktop.
Select ? random records
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 title | |
| FROM table AS t1 | |
| JOIN (SELECT (RAND() * (SELECT MAX(id) FROM table)) AS id) AS t2 | |
| WHERE t1.id >= t2.id | |
| ORDER BY t1.id ASC | |
| LIMIT ?; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment