Reputation: 153
I have a database table like :
+---+-------------+
|id |ship_method |
+---+-------------+
| 1 |freeshipping |
| 1 | flatrate |
| 2 | DHL |
| 3 | matrixrate |
| 1 | courier |
+---+-------------+
So, I want to update ship_method from frontend form based on multi option selected. For eg : if Id 1 selects freeshipping , DHL , matrixrate then the corresponding values of ship_method should be updated.
What is the mysql query to update in this case. I tried but couldn't find how to update such multiple rows at once.
Upvotes: 0
Views: 40
Reputation: 12085
Delete previous data and insert new all
delete from table where id=1;
insert into table_name(id,ship_method) values(1,'freeshipping'),(1,'DHL'),(1,'matrixrate');
Upvotes: 1