sql - MySQL Order of Index Checks -


i running mysql , have simple table below:

create table `new_schema`.`test1` (   `id` int not null auto_increment,   `unique1` varchar(45) null,   `unique2` varchar(45) null,   primary key (`id`),   unique index `unique1_unique` (`unique1` asc),   unique index `unique2_unique` (`unique2` asc)); 

i add row such:

insert `new_schema`.`test1` (`unique1`, `unique2`) values ('x', 'x'); 

i add row same values in unique unique columns:

insert `new_schema`.`test1` (`unique1`, `unique2`) values ('x', 'x'); 

i error expected:

11:54:06    insert `new_schema`.`test1` (`unique1`, `unique2`) values ('x', 'x')   error code: 1062. duplicate entry 'x' key 'unique1_unique'  0.203 sec 

my question is, how change order in mysql checks unique values entered. so, given example above, provided 2 violations of unique entries (unique1 , unique2), want check unique2 first, error this:

11:54:06    insert `new_schema`.`test1` (`unique1`, `unique2`) values ('x', 'x')   error code: 1062. duplicate entry 'x' key 'unique2_unique'  0.203 sec 

thanks, mark

have trie change position that

    unique key index `unique_unique` (`unique2`,`unique1`) 

like that:

 create table `new_schema`.`test1` (    `id` int not null auto_increment,    `unique1` varchar(45) null,    `unique2` varchar(45) null,   primary key (`id`),  unique key index `unique_unique` (`unique2`,`unique1`)  ); 

Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -