How can we generate Random alphanumeric number in mysql? we can generate random number using rand()? But i dont know about how to generate alphanumeric number?

Lol, I'm not sure what question I'd be responding to but here goes...

Many random number generators generate a float from 0 to 1. Java is friendly in that it gives you some other features like random generating integers, longs, etc, but all you really need is a float from 0 to 1. Lets call this number SuperR.

Let's say you want a random number from 200-1000. Well, the range of that number is 800 (1000-200) so what you really want is 200 + (some number from 0-800). So you take the range, 800, multiply it by SuperR, (think of this as percentage, you want 0-100% of 800), and then add 200. In the case of integers, then just call floor/top to round the number to the nearest integer.

Now, in the case of alphanumerics, the first question is "what do you consider alpha numerics?" such as do you consider letters with accent marks, spaces, commas, ASCII characters, or other things alphanumerics. Once you decide that you can then make a character array out of them lets say that has 50 elements. Put one character in each spot in the array. Next, generate a random number from 0-49 (as previously described) and use that as an index into the array.

As for mysql... any solution would be database-dependent so you should do the coding in java. [ July 11, 2006: Message edited by: Scott Selikoff ]