Guest purnendu Posted July 3, 2006 Share Posted July 3, 2006 CREATE TABLE `category` ( `catid` varchar(15) NOT NULL default '0' auto_increment, `catname` varchar(50) default NULL, `status` varchar(50) default NULL, PRIMARY KEY (`catid`), KEY `catid1` (`catid`), KEY `cat` (`catname`) ) TYPE=InnoDB COMMENT='InnoDB free: 3072 kB' I have created one table category where column catid as varchar and autoincrement, but in want to insert record into database as "A00001", "A00002", "A00003" like that as a autogenerated with the help of codinginto frontend.Plz help mePurnendu Quote Link to comment https://forums.phpfreaks.com/topic/13526-how-to-generate-autoincrement-number-using-frontend/ Share on other sites More sharing options...
.josh Posted July 3, 2006 Share Posted July 3, 2006 you can't auto_increment a varchar column type. it has to be an integer type. now what you CAN do is make a varchar and set it to be unique. then select it, ordered by itself descending order limit 1, and use php to split the letters from the numbers to find out the next number, then build the next apha numeric string for insertion. Quote Link to comment https://forums.phpfreaks.com/topic/13526-how-to-generate-autoincrement-number-using-frontend/#findComment-52370 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.