Web Hosting Talk







View Full Version : Does rand() with mysql produce duplicates?


buccaneerob
10-27-2004, 02:25 AM
I'm using the rand() function in a sql statement with php to obtain a certain amount of random items, now my question is will it include duplicates?

I want all of the items to be unique..... anyone who has some knowledge of this please help!

Thanks!
Rob

buccaneerob
10-27-2004, 02:29 AM
nevermind answered my own question, looks like it doesnt

tiamak
10-27-2004, 11:51 PM
sure it does - same as md5 creates duplicate (but only few was found :D)
in rand() case all depends how long you want to use created number and how long it is :)
i/e if it has 3 digits :) and you want to use it "forever" (for example as ID for your products) :) you will meet duplicates very soon :)