MySQL INSERT with two different UNIQUE constraints -
i have table created with:
create table usersessions ( id integer not null auto_increment, userid varchar(50) not null, starttime timestamp null, endtime timestamp null, primary key (id), index(starttime), index(endtime), unique(userid, starttime), unique(userid, endtime) );
and want know, if inserting row has duplicate key, on constraint duplicate, on starttime or on endtime. know how it?
name constraints:
create table usersessions ( id integer not null auto_increment, userid varchar(50) not null, starttime timestamp null, endtime timestamp null, primary key (id), index(starttime), index(endtime), unique idxstarttime(userid, starttime), unique idxendtime(userid, endtime) );
when insert fails error state constraint violated:
#1062 - duplicate entry 'value' key 'idxstarttime'
Comments
Post a Comment