0

I want to use SQL's RAND()-function to get the number 400, 450 or 500 and insert it in a field inside a tabe.

How could I do that?

Sainan
  • 1,244
  • 1
  • 20
  • 32
  • 4
    Possible duplicate of [How to get mysql random integer range?](http://stackoverflow.com/questions/984396/how-to-get-mysql-random-integer-range) – 1000111 Aug 17 '16 at 10:19
  • I don't want a result of 401 or 498 or 432... There is only 3 possibles values (400 OR 450 OR 500) – user2799086 Aug 17 '16 at 10:25

2 Answers2

1

I think you can follow code bellow

a = floor(rand() * 3);
value = 400 + a*50; 
1

First genterate ints from set [0,1,2] then multiple to 50 to get step in 50 then add seed

select floor(rand() * 3)  * 50 + 400
Hamlet Hakobyan
  • 32,360
  • 6
  • 50
  • 66