php: quickest way to generate a 5-digit number not already in MySQL db column (with a unique attribute)
问题 Suppose Table1 contains column orderid (not a key, although it's NOT NULL and unique). It contains 5-digit numbers. What's the best way to generate a php var $unique_var that is not in that column. What could be important, from 10% to 30% of 5-digit numbers are in the table (so generating a number and checking while (mysql_num_rows() ==0) {} is not a best way to find one, are there any better solution for performance?). Thank you. 回答1: If there is just 10-30% of numbers already taken - then