Skip to content

Instantly share code, notes, and snippets.

@asika32764
Created August 16, 2014 07:41
Show Gist options
  • Save asika32764/534ad8891a2a3bb8fe05 to your computer and use it in GitHub Desktop.
Save asika32764/534ad8891a2a3bb8fe05 to your computer and use it in GitHub Desktop.
Mysql Rand() between 2 values
ROUND((RAND() * (max-min))+min)
@Wiimm
Copy link

Wiimm commented Sep 19, 2018

Really, 1 repository for 1 buggy code line?

For range (min..max( (min inclusive, max exclusive) it is:
FLOOR( RAND() * (max-min) + min )

For range (min..max) (min+max inclusive) it is:
FLOOR( RAND() * (max-min+1) + min )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment