Skip to content

Instantly share code, notes, and snippets.

@skazhikadyadya
Last active March 22, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skazhikadyadya/5c78f8cfffab22aa08a1b8c1146af1f6 to your computer and use it in GitHub Desktop.
Save skazhikadyadya/5c78f8cfffab22aa08a1b8c1146af1f6 to your computer and use it in GitHub Desktop.
Random strings from DB #mysql
SELECT * FROM table AS r1
JOIN (SELECT (RAND()*(SELECT MAX(id)-MIN(id) FROM table) +
(SELECT MIN(id) FROM table)) AS id) AS r2
WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment