$query = mysql_query("UPDATE a SET fruit = '**apple**' WHERE id = '**1**' "); $query2 = mysql_query("UPDATE a SET fruit = '**orange**' WHERE id = '**2**' "); $query3 = mysql_query("UPDATE a SET fruit = '**peach**' WHERE id = '**3**' ");
is there any way to simplify it to one query?
I found a following solution:
INSERT into `table` (id,fruit) VALUES (1,'apple'), (2,'orange'), (3,'peach') ON DUPLICATE KEY UPDATE fruit = VALUES(fruit);
Id must be unique or primary key. But don't know about performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With