Portal Home > Knowledgebase > Articles Database > mysql query update


mysql query update




Posted by ti_nhatrang, 11-03-2010, 02:51 PM
Hi all, I got about 20 rows inside my table, and I want to divide each row up even or somewhat even that is >=100 inside the balance column... for example, if I have 4 rows, each row would get '25' in the column 'balance'.... Please help me achieve this if you could, thank you.

Posted by virtualnoc, 11-04-2010, 03:39 PM
Your objective doesn't seem to be quite clear... If the 'balance' of a row is >= 100 you want to dived it into 4 equal parts and add each part into new rows? Is that correct? If that's accurate, I would do this using your code of choice... 1) select * where balance >= 100; 2) In your code of choice, divide the balance by 4 3) Add four new rows with the divided balance 4) If the four new rows are added successfully, remove the original row.

Posted by TheDandy, 11-06-2010, 11:27 AM
You should use: That will return the same value for all the rows, automatically. I assume you have a DECIMAL or FLOAT type in that field, as the division might return a decimal of course.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
MCHOST v HTTPME (Views: 889)
Deciding on host ... (Views: 756)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.