How to use php to batch process mysql data? Hope the experts can give the code directly. thank you! For example, if a database contains several data records and you want to add and insert the two fields in each data record into another field:
Cca ccb ccd id
45 66 0 1
67 36 0 2
86 24 0 5
76 84 0 8
6 55 0 12
......
A single entry is calculated as follows:
simplequery($q);$a=$obj_db->fetchRow($r,DB_FETCHMODE_ASSOC);$ccd=$a[cca]+$a[ccb];$obj_db->simplequery("update member set ccd='$ccd' where id='5'");?>
Is there any way to calculate each piece of data in batches? Please provide detailed Code. thank you!
Reply to discussion (solution)
$obj_db->simplequery("update member set ccd=cca+ccb where id='5'");
$obj_db->simplequery("update member set ccd=cca+ccb where id='5'");
Like ..
$ Obj_db-> simplequery ("update member set ccd = cca + ccb ");
$ Obj_db-> simplequery ("update member set ccd = cca + ccb ");
This is what the landlord requires. the whole table is handled once.
This is the standard SQL. it has nothing to do with php. grammer: update tablename set cloum = ''where ..
$ Obj_db-> simplequery ("update member set ccd = cca + ccb ");
Thank you! Continue to ask:
If you want to determine whether the value of cca + ccb> 110 is calculated, how can this problem be solved:
$ Obj_db-> simplequery ("update member set ccd = cca + ccb where sum (cca + ccb)> 110 ");
Please help me correct the code. thank you!
Update member set ccd = cca + ccb where cca + ccb> 110
Update member set ccd = cca + ccb where cca + ccb> 110
Thank you.