hi. I have a rather childish question on tables and auto increment fields. Scenario: I have a table with an <int auto increment primary key> field. The deal is that everything works fine (I'm talking about the auto incrementation part) until I choose to delete a row. This creates a gap in the primary key field. And my question is: I'd like to know if there is an easier way to keep track of these gaps, instead of specifically iterating through the table and stopping where you find one. To accomplish this, I use this function:
function GetUntakenNrCrt($tabel) { $nrCrt = 1; while(1>0) { if(!GetSingle("select nrcrt from $tabel where nrcrt='$nrCrt'")) return $nrCrt; $nrCrt++; } } function GetSingle($query) { $q = mysql_query($query); if(mysql_num_rows($q) > 0) while($p = mysql_fetch_row($q)) return $p[0]; else return false; } The reason is that I want a table with continous records in the primary key field (1, 2, 3... instead of 1,6,23...). Can anyone suggest a different (and easier) method? Thanx a lot! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]