![]() REPLACE INTO customer_data(customer_id, customer_name, customer_place) VALUES(2, "Hevika","Atlanta") Īction Output Message : 18:27:57 REPLACE INTO customer_data (customer_id, customer_name, customer_place) VALUES(2, “Hevika”,”Atlanta”) 2 row(s) affected 0.0023 secĭoing a select * again on customer_data gives the data as shown in figure 1.5. Observe the below query with an action output message received after running it. We will be using the same example from customer_data table. The difference is: If the new row to be inserted has the same value of the PRIMARY KEY or the UNIQUE index as the existing row, in that case, the old row gets deleted first before inserting the new one. Insert or Update into MySQL Table : using REPLACE INTO Read more about ON DUPLICATE KEY UPDATE in the official documentation. It shows that since the key value is duplicated, query updated the row with new customer_name and customer_place values. Select * on customer_data will give the below output. Let us see how the row with customer_id = 2 looks now. 0 if an existing row is set to its current values.It says 2 rows affected as ON DUPLICATE KEY UPDATE displays the affected-rows value: VALUES(2, "Vaani","Denver") ON DUPLICATE KEY UPDATE customer_name = "Hevika", customer_place = "Denver" Īction Output Message : 14:26:12 INSERT INTO customer_data (customer_id, customer_name, customer_place) VALUES(2, “Vaani”,”Denver”) ON DUPLICATE KEY UPDATE customer_name = “Hevika”, customer_place = “Denver” 2 row(s) affected 0.0037 sec INSERT INTO customer_data (customer_id, customer_name, customer_place) Select all columns except one of a MySQL table.Python - Access Nth item in List Of Tuples Python - Check if a value is in Dictionary Python - Returning Multiple Values in Function Check if String Contains SubString (Case Insensitive) in PHP. ![]() Check if String Contains Any of Array in PHP.Looking for Something Search for: Search Recent Posts ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |