By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

How to automatically increment value in mysql

P: 3
hi,
i have created one table called user_details for this table there is one
column called uid,which should increment automatically,when ever i insert
values

for this i have create table by using auto_increment,table created seccussfully,
bt if i insert values into this table by excluding tat uid(which is increment automatically),it is showing error column count doesnt match value of row count.

anybody knows where i was error,
ur reply greatly appreciate.

thanks
khan
Dec 13 '07 #1
Share this Question
Share on Google+
2 Replies


code green
Expert 100+
P: 1,726
i insert values into this table by excluding tat uid
Not sure what you are doing here but you must define the field names along with the values
Dec 13 '07 #2

mwasif
Expert 100+
P: 801
You should provide the filed names in the query leaving uid. e.g.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_name (firstname, lastname) VALUES ('M', 'Wasif')
Or without field names
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_name VALUES ('', 'M', 'Wasif')
OR
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table_name VALUES (NULL, 'M', 'Wasif')
The first method is preferable.
Dec 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.