mysql - UPDATE on duplicate columns when three are duplicate but not just one -



mysql - UPDATE on duplicate columns when three are duplicate but not just one -

i'm implementing mysql database uses x/y/z primary key structure, x , y foreign keys , z local key.

my predicament don't want duplicate case activated unless 3 duplicated. assuming have table structure.

x | y | z | description 34 | f4 | 25 | row 34 | f4 | 26 | row c6 | 71 | 9a | row

if wanted insert

x=34,y=f5,z=25,description=this row

it insert new row because although x , z duplicates, y not. however, if sent

x=34,y=f4,z=25,description=this first row

it should update entries description.

can insert ... on duplicate key, or there more complex needs done?

of course of study can. need declare (x,y,z) primary or unique key:

create unique index idx_table_x_y_z on table(x, y, z)

if triplet exists in table, can utilize on duplicate key insert.

mysql sql duplicates upsert

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -