contra10 Posted April 12, 2009 Share Posted April 12, 2009 I just want to know that if i have an auto incremented table and the auto incremented numbers are lets say 1,2,3,4 to represent each row. If i delete row 2, whats left in my database is 1,3,4. The next input would be 5. 1,3,4,5. Question: Is there a way to allow the next created row to be 2 instead of being 5? I guess I'm just trying to reorganize Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/ Share on other sites More sharing options...
MasterACE14 Posted April 12, 2009 Share Posted April 12, 2009 I'm not sure, but you might be able to use PHP to find the first missing number, and then set that as the value to insert in the auto increment column. Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807712 Share on other sites More sharing options...
contra10 Posted April 12, 2009 Author Share Posted April 12, 2009 so should my script be something like "ALTER table"...although i wouldn't know what top put... is there a way in php my admin Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807716 Share on other sites More sharing options...
revraz Posted April 12, 2009 Share Posted April 12, 2009 Auto Increment is just that, you can't force a number into the field. And why would you want to? Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807721 Share on other sites More sharing options...
contra10 Posted April 12, 2009 Author Share Posted April 12, 2009 i'm afraid that eventually my number is going to be too high, plus i really am not a fan of long urls... but i was looking around and there's suppose to be an alter code...this is what im doing but doesn't really work ye i guess ill just deal with it Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807726 Share on other sites More sharing options...
nankoweap Posted April 12, 2009 Share Posted April 12, 2009 if you want that kind of control over an ID column, i'd suggest not using auto increment and write the code to do it yourself. of course, i'm not sure why one would want to do this. i mean, what value-add to the application and its users would justify this? i make my ID columns unsigned bigints and don't worry about it. jason Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807733 Share on other sites More sharing options...
revraz Posted April 12, 2009 Share Posted April 12, 2009 The Alter command sets the Autoincrement value to something different, not allows you to put a number in the field. Quote Link to comment https://forums.phpfreaks.com/topic/153702-simple-sql-question/#findComment-807742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.