elioncho Posted October 9, 2006 Share Posted October 9, 2006 HI, I have a table that looks something like this:CREATE TABLE orders( ID INT(5) AUTO_INCREMENT NOT NULL, name VARCHAR(40) NOT NULL, date DATE NOT NULL,PRIMARY KEY(ID,date) )I want to change the value of ID to 1 again after certain time. What MySQL query can I use to make the field ID begin autoincrementing from number 1 again. Thanks.. Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/ Share on other sites More sharing options...
AndyB Posted October 9, 2006 Share Posted October 9, 2006 Why would you want to do that? The auto-increment value is an intrinsic part of the database, not some field you should manipulate at will. Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-106535 Share on other sites More sharing options...
elioncho Posted October 10, 2006 Author Share Posted October 10, 2006 Because I want that everytime a new year starts the count to begin at 1. Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-106567 Share on other sites More sharing options...
pootlecat Posted October 10, 2006 Share Posted October 10, 2006 It seems you want to know the same thing as me :)I haven't found anywhere on Google that suggests it is even possible but hopefully someone here will know! Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-106572 Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 I've posted elsewhere on how to do this, much to my shagrin... if you want to empty out the table properly, TRUNCATE it, and MySQL will take care of the rest. Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-106883 Share on other sites More sharing options...
pootlecat Posted October 10, 2006 Share Posted October 10, 2006 I don't know about elioncho but I want to keep my data and just redo the auto_increment column :) Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-107006 Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 The question is "why?"... Link to comment https://forums.phpfreaks.com/topic/23460-changing-auto-increment-value/#findComment-107093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.