mysql-error-1062

Cant make field unique!

Can you not have more than 2 unique fields in a table or am i doing something wrong here? I have 1 unique key for username and i want it for email too but i get #1062 - Duplicate entry '' for key 'email' alter table users add unique (email) Tbl: `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `...

Foreign key constraints while dumping data

mysqldump --compact --no-create-info -h192.168.150.180 -uroot -p live pnlbus_stops | sed s/pnlbus_stops/bus_stops/g | mysql test I am getting an error: ERROR 1062 (23000) at line 1: Duplicate entry 'AN' for key 1 This is because bus_stops table in the test DB has foreign key constraints. How do I truncate the bus_stops table from test...

Mysql INSERT SELECT problem (funny)

I have a table with primary key id AUTOINCREMENT and some other attributes. I have many rows with attribute lang='en'. and I do DELETE FROM ".MY_PRF."form WHERE `lang` <> 'en' I want to COPY all them changing lang to 'cz' I use: INSERT INTO form (`lang`, `caption`, `type`) SELECT 'cz', `caption`, `type` FROM form WHERE lang = 'e...

MySQL: Duplicate Entry for Key 2

I'm not sure what I'm doing to cause this error. The query: INSERT INTO node (type, language, title) VALUES ('bout', 'en', 'the title 3') The error: #1062 - Duplicate entry '0' for key 2 The table: CREATE TABLE `node` ( `nid` int(10) unsigned NOT NULL auto_increment, `vid` int(10) unsigned NOT NULL default '0', `type` varch...

MySQL composite unique on FK's

I want to implement the following constraints in mysql: create table TypeMapping( ... constraint unique(server_id,type_id), constraint foreign key(server_id) references Server(id), constraint foreign key(type_id) references Type(id) ); This throws a 'ERROR 1062 (23000): Duplicate entry '3-4' for key 'server_id'' when...

PHP MySQL INSERT fails due to unique constraint

On insert I am catching the unique constraint mysql_errno() 1062. This works fine but I want to find the existing row to re-instate or modify it. Is there are method to obtain the row id on insert fail? I tried mysql_insert_id() but realised that would only return the row I'm inserting (or failed to insert) therefore, I get 0. Is the...

phpmyadmin error "#1062 - Duplicate entry '1' for key 1"

I dropped all tables from a database then restore(import) a backup. and getting this error. Should i repeat the process. or something else? Why this error is coming? ...

How to restore data from MYSQL dump without any duplicate key errors?

Everytime I try restoring the dump, I get : ERROR 1062 (23000) at line 10297: Duplicate entry 'spaß' for key 'PRIMARY' I am trying to restore it using: mysql -u root -ppassword database < 0719.sql ...

Combine two columns together from separate tables

Let's say for instance: I have two tables: old_data and new_data. Both old_data and new_data have one column called this_is_col. Both old_data and new_data have various (hundreds) of rows of dates (2010-02-06, 2010-01-09, 2007-06-02, etc.). Both tables don't necessarily have the same dates, but they both have the same format. The fiel...

phpMyAdmin error #1062 - Duplicate entry '1' for key 1

I am not sure why I am getting this error #1062 - Duplicate entry '1' for key 1 cany any one help explain what it means. Thanks ...

PHP Doctrine - Integrity constraint violation: 1062 Duplicate entry (Primary key)

I'm loading lots of User and related Group objects from a custom PDO query (using the Doctrine connection => $dbh = Doctrine_Manager::connection()->getDbh(); ). The query involves a cross join which isn't supported in DQL. I'm manually creating the objects and passing the values like so: foreach($pdo as $p) { $u = new U...

Mysql unique index does't work on a certain umlaut

I have a users table in which there's a column called 'nickname', utf-8 encoded, varchar(20), the table is in InnoDB. There're 2 records one has a nickname = 'gunni' and the other nickname = 'günni'. When I tried to apply a unique index onto this column, mysql gave me this error : ERROR 1062 (23000) at line 263: Duplicate entry 'gun...

get keyname for constraint error in PHP/MySql?

If I try to do an insert that fails because of a key constraint error, is there a way I can get the name of the key without doing string parsing of the error text? I already know the error code is 1062; I want to find out which key constraint failed :) ...

Converting from 5.0.27 to 5.1.41, getting duplicate key errors (1062)

I have a database that's currently running on a 5.0.27 server. I want to move to a new 5.1.41 server. I mysqldump'd all the files. When restoring, I get an error ERROR 1062 (23000) at line 21: Duplicate entry 'weiÃ' for key 'title' I've narrowed the failure down to this script, which I can run and it fails: -- -- Table structure ...

Problem loading Django fixture: IntegrityError: (1062, "Duplicate entry '4' for key 'user_id'")

I used the following commands to generate 2 fixtures: ./manage.py dumpdata --format=json --indent=4 --natural auth.User > fixtures/user.json ./manage.py dumpdata --format=json --indent=4 --natural --exclude=contenttypes --exclude=auth > fixtures/full.json I've got the following fixture named user.json: [ { "pk": 4, ...