php - mysql multiple unique keys with on duplicate key reference -


i have table structure

id,f1,f2,f3,f4 

id primary key , f1 , f3 unique keys

my question when use on duplicate key update

which key considering valuation

consider query

insert t1 (f1,f2,f4) values (.....) on duplicate key update f4=...." 

as shown above consider key f1 ? or f3 or id

and if have query this

insert t1 (f1,f2,f3,f4) values (.....) on duplicate key update f4=...." 

what key consider ?

thanks guys :)

from mysql manual, emphasis mine:

if specify on duplicate key update, , row inserted cause duplicate value in unique index or primary key, update of old row performed.

an insert attempt cause duplicate unique constraint on table cause alternative action triggered. note advised (in general) not use on duplicate key syntax tables contain multiple unique indexes:

in general, should try avoid using on duplicate key update clause on tables multiple unique indexes.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -