SJames Posted August 30, 2007 Share Posted August 30, 2007 When using an "INSERT INTO" statement, what should I put as the value for an auto incrementing cell? ex: "INSERT INTO content VALUES (' [auto-incrementing field] ', '$content')"; Would I just leave it empty? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Do your queries like this: INSERT INTO tablename(column1, column2, etc) VALUES(value1, value2, etc) Then simply don't list the auto-increment field in either the columns list or values list. Quote Link to comment Share on other sites More sharing options...
SJames Posted August 30, 2007 Author Share Posted August 30, 2007 That makes sense, thank you. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Sure thing. Also, you can use it to leave fields NULL or other default values by leaving them out. It's handy to do it this way, because if you need to add another column, you can ensure it has a default value and you won't have to edit ALL of your code, at least not immediately. 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.