Mysql Random Number Between 1 and 100 – Query Examples

Mysql Random Number Between 1 and 100

Rand() function is used to select random numbers in Mysql. This function doesn’t get parameters. Returns a value between 0 and 1. To get a value between 0 and 100, we must multiply the value by 100 then round it up.

Example:

Example

Example:

Example

So if we use Ceiling method never return 0 value. For random number between 1 and 100 on mysql, we must use the code below.

If we want to get value between 0 and 100 the we must use the code below.

About the author

Thomas Brown

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: