![]() |
1062 : Duplicate entry 'xxx' for key 2
Hello,
When I try to mysql insert values with same names, it encourages this error. When I looked at the table column, I see that the row id is always "1" and it doesnt let to add same entry. ![]() My question is, how can I add an auto increment id to that column for adding same entry names? |
If the field has an auto_increment attribute then you don't need to insert a value in that field. But using a COUNT query wouldn't return the id numbers, query your table like this (I am assuming your auto_increment query is aut_id):
SQL Code:
|
My problem is, I can't add new user if the new user's firstname (aut_username) was used before.
![]() I can add new column for firstname, but could you please tell me how to make it that lets you add same entry names. |
Can you show us your table structure? What your telling us doesn't seem right unless you have a problem with your structure.
|
It sounds like there's a PRIMARY or UNIQUE index on that column. Since you're using phpMyAdmin, click on the link at the bottom of the Structure tab that says 'Details'. Find the one for aut_username and change it from UNIQUE to INDEX.
GUI FTW. :) |
Quote:
|
I was only just starting my second pot of coffee when I wrote that, so you'll have to forgive the oversight; normally username columns are set to UNIQUE for a reason. You don't want two users with the same username, as you might run into a plethora of conflicts, not the least of which would be signing in.
|
| All times are GMT. The time now is 03:36 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0