random number in MySQL with range

I am creating a prototype that needs to simulate adding IDs from 1-7. Since i’m lazy i updated the new column with a random numnber.


MySQL has a rand() function which will give you a floating point, multiply it by the range you need and add 1.

Note: this post serves as a note for future reference

Leave a Reply

Your email address will not be published. Required fields are marked *