Kali ini kita akan mencoba salah satu perintah di mysql untuk keperluan update atau perubahan dalam tabel serta juga kita akan mencoba untuk memberikan primary key kepada salah satu dalam tabel.. A primary key must be unique. so you cannot change one record to have the same pk as an existing record. for example if you get any records from the sql below then the update you want to perform cannot be done.. The statement above sets the value of the c1 to its current value specified by the expression values(c1) plus 1 if there is a duplicate in unique index or primary key. mysql insert on duplicate key update example. let’s take a look at an example of using the insert on duplicate key update to understand how it works..
I have a mysql table with an auto-incrementing column (uid) as the primary key. users can view records in this table via a php form, with uid being either a $_get or $_post variable, depending on whether the user clicks a link or manually enters the uid.. Auto increment - mysql automatically increases the value of the field by 1 each time a new record is added; primary key - used to uniquely identify the rows in a table. the column with primary key setting is often an id number, and is often used with auto_increment; each table should have a primary key column (in this case: the "id" column).. Ah, thats excellent to know - thank you for responding. i can change my db to accomodate this easily now, but did spend a lot of time on it yesterday, but hopefully this can be rectified in future versions..
0 komentar:
Posting Komentar