Update MySQL: Duplicate unique key #1062 -


i have table this:

create table if not exists `activity` (   `id` int(8) not null auto_increment,   `action` tinyint(1) not null,   `userid` int(8) not null,   `categoryid` int(8) not null,   primary key (`id`),   unique key `unique` (`userid`,`categoryid`),   key `categoryid` (`categoryid`) ) engine=innodb  default charset=utf8 collate=utf8_unicode_ci auto_increment=2 ; 

with next information:

insert `activity` (`id`, `action`, `userid`, `categoryid`) values (1, 2, 11, 312); 

i'm trying execute query:

update `activity` set `action` = '3' `userid` = '11' , `categoryid` = '312' ; 

and response me that:

duplicate entry '11-312' key 'unique' 

i don't know why. ain't changing unique keys or inserting new record. problem?

thanks.

i don't know why, when export whole database, instead of show before sql, show this:

create table if not exists `activity` (   `id` int(8) not null auto_increment,   `action` tinyint(1) not null,   `userid` int(8) not null,   `categoryid` int(8) not null,   primary key (`id`),   unique key `unique` (`action`,`userid`) ) engine=innodb  default charset=utf8 collate=utf8_unicode_ci auto_increment=2 ; 

now rewrite setup table sql , works.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -