MySQL update multple rows in one instruction

  • elektric
  • Graduate
  • Graduate
  • User avatar
  • Posts: 130
  • Loc: Mexico

Post 3+ Months Ago

Hello everyone, I need some help today.

I'm building a script to update X range of rates, this "rates" table is something like this:

Code: [ Select ]
+------+----------+------+------+
| city | location | date | rate |
+------+----------+------+------+
  1. +------+----------+------+------+
  2. | city | location | date | rate |
  3. +------+----------+------+------+


I made another script that displays X number of fields depending on the date range, for example if I select from Jan-1 to Jan-3, it will display 3 fields with the current rates on the database for those specific dates, each field dynamicaly generated with a consecutive number. e.g.

Code: [ Select ]
 
<input name="rate1" type="text" id="rate1" value="90">
<input name="rate2" type="text" id="rate2" value="100">
<input name="rate3" type="text" id="rate3" value="80">
 
  1.  
  2. <input name="rate1" type="text" id="rate1" value="90">
  3. <input name="rate2" type="text" id="rate2" value="100">
  4. <input name="rate3" type="text" id="rate3" value="80">
  5.  


Quote:
(The reazon of having the fields dynamicaly generated is because rates are automaticaly passed with javascript to next fields to make rate updating work easyier.)


Now the thing is, I need all these fields to update their corresponding row, but this would cause an INSERT instruction for each field, considering that some times we may update 50+ rows at the time I am not sure but seems unconvenient talking about MySQL load.

Do you know of a better way to do this?

Thank you all.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 136 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.