jfs0479 Posted April 11, 2007 Share Posted April 11, 2007 Hi Guys, I am currently working on a project that requires members to have auto_assigned ID with charcters infront of them like ARB1 or ARB589 . Below i have the sql query i have currently but i would like it so that i could have it in the explained fromat not just 1 or 446 create table arab_members ( memberid int(5) unsigned NOT NULL auto_increment, forename varchar (255), surname varchar(255), country varchar(255), email varchar(255), reason text, age int, sex varchar(100), hub varchar(255), previousva varchar(255), password varchar(255), level int, rank varchar(255), activate text, registerdate text, lastactive text, ip int, PRIMARY KEY (memberid) ); Thanks James Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/ Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 I understand you need this for the output, but why do you need it in the table itself? Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/#findComment-226713 Share on other sites More sharing options...
wildteen88 Posted April 11, 2007 Share Posted April 11, 2007 auto_increment only works with integers and not string If you want to use strings then you will have workout the auto_increment value yourself with the processing script that enters the data into the database. Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/#findComment-226714 Share on other sites More sharing options...
jfs0479 Posted April 11, 2007 Author Share Posted April 11, 2007 However when you process the scipt it only ads the integer not the letters before it but how can i change that? Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/#findComment-226741 Share on other sites More sharing options...
wildteen88 Posted April 11, 2007 Share Posted April 11, 2007 You will have to turn auto_increment off on that column and change the data type for that column to VARCHAR, as you are now dealing with a string and not an integer integers cannot have letters/symbols only numbers. 0 through to 9 If keep it as INT mysql will strip any non numerical character out and only store the numbers. Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/#findComment-226747 Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 I will ask again, why do you feel the need to store this in the DB itself? Quote Link to comment https://forums.phpfreaks.com/topic/46575-initial-values-with-ints/#findComment-227082 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.