Skip to content

Instantly share code, notes, and snippets.

@akeinhell
Created February 11, 2015 08:10
Show Gist options
  • Save akeinhell/b4ee02e6ab8d128fb1c4 to your computer and use it in GitHub Desktop.
Save akeinhell/b4ee02e6ab8d128fb1c4 to your computer and use it in GitHub Desktop.
Выбор случайной строки в Mysql
SELECT FLOOR(count(*)*RAND()) INTO @max FROM table;
PREPARE STMT FROM 'SELECT * FROM table LIMIT ?,1';
EXECUTE STMT USING @max;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment