Reseting auto increment field
Moderator: General Moderators
Reseting auto increment field
How to reset the value of auto increment field to 1 . i have id field in my table if i delete all record from that table and when i insert new record it assign next available id it doesnt start from 1 again so how 2 reset it to 1 .
-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
try
Code: Select all
ALTER TABLE tbl_name AUTO_INCREMENT = 1me i created a variable that will increment my Primary key
i use access db.. but you can change the syntaxe to fit mysql.. but me it works..
i dunno if i help ya but i tried
Code: Select all
<?php
while(odbc_fetch_row($queryexe))
{
$varkey = odbc_result($queryexe, 1); /*where 1 is in fact the field i need you might need to change it for 2 3 or whatever */
}
$var = $varkey;
if ($var == "NULL") {
$var == 1;
}else{
$var++;
}
?>i dunno if i help ya but i tried