proggR Posted July 23, 2008 Share Posted July 23, 2008 I have a db setup and a table with the columns postID, file, title, course, date and directory. postID is the primary key and is set to auto increment. When I go to insert the values do I skip the postID and start on the file or do I have to insert the postID everytime? or just the first time? I'm assuming INSERT INTO table VALUES ('$file', '$title', '$course', '$date', '$directory') would throw an error since it would see the first value in $file and try to insert it in the postID columb which is an INT (wheras file is VARCHAR). Could anyone clarify this? Quote Link to comment Share on other sites More sharing options...
accident Posted July 23, 2008 Share Posted July 23, 2008 Just throw in a null and that will auto increment so for example INSERT INTO table VALUES (null, '$file', '$title', '$course', '$date', '$directory') Quote Link to comment Share on other sites More sharing options...
proggR Posted July 23, 2008 Author Share Posted July 23, 2008 Ok thanks. I also realized i could go INSERT INTO table (file, title etc....) but that's just a hassle so thank you . And also, with the auto increment, does it default my first value to one so i NEVER have to enter anything for it. Or do i have to initialize it at one the first time its used? Quote Link to comment Share on other sites More sharing options...
accident Posted July 23, 2008 Share Posted July 23, 2008 It will default to one on your first insert unless you run this command on your table ALTER TABLE tbl AUTO_INCREMENT = 1000 which will start the value at 1000 instead of 1 Quote Link to comment Share on other sites More sharing options...
proggR Posted July 23, 2008 Author Share Posted July 23, 2008 Ok thanks All I needed to know (for now ) Quote Link to comment 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.