Will RAND(1,100000) pick a number between 0 and 1 million or does it only go up to 32,000 or whatever RAND_Max is?
I tested past RAND_MAX (in my case 232 - 1), and it returned a negative integer, presumably due to overflow.