Skip to content

Instantly share code, notes, and snippets.

@Vladnev
Created October 27, 2017 14:37
Show Gist options
  • Save Vladnev/cff0df0607b86d73ae409ff0cf2cbf24 to your computer and use it in GitHub Desktop.
Save Vladnev/cff0df0607b86d73ae409ff0cf2cbf24 to your computer and use it in GitHub Desktop.
Random row sql
SELECT r1.id
FROM forms AS r1 JOIN
(SELECT (RAND() *
(SELECT MAX(id)
FROM forms)) AS id)
AS r2
WHERE r1.id >= r2.id
ORDER BY r1.id ASC
LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment