I would like to generate a 5 digit number which do not repeat inside the database.
Say I have a table named numbers_mst with field named my_number.
I want to generate the number the way that it do not repeat in this my_number field.
And preceding zeros are allowed in this. So numbers like 00001 are allowed.
Another thing is it should be between 00001 to 99999. How can I do that?
One thing I can guess here is I may have to create a recursive function to check number into table and generate.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…