What could be the best solution to create about 300,000 random numbers with 9 digits,without repitition and insert them in to a table ?I have used this method :for($j=1;$j<=300000;$j++){//number of records to insert $string=""; $snum='637419582016'; for($i=1;$i<=9;$i++){ $rnumb=rand(0,11); $string.=$snum[$rnumb]; }//------------checks the repitition by one query of the tableif ($totalRows_Recordset1>0) { $tempreg=$j-1;$regstatus="<B>ERROR- Repetitive Key Generation,</B> Generated ".$tempreg." key(s) out of 300000 keys";break;} It worlk well and takes every 1000 random number in one second to the table, but the repitiion occurs too soon in the 12000th to 20,000th number generation, Could there be a way to generate all numbers without the repition check ?