How to use php to batch process mysql data? Hope the experts can give the code directly. thank you!

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.