How do I add filters when I process MySQL data in batches? The master can give the code directly, thank you

Source: Internet
Author: User
How do I add filters when I process MySQL data in bulk? Please master can directly give the code, thank you!
For example, there are several data in the database, you want to add two fields in each data CCA and CCB together divided by three fields CCA, CCB and CCD to get the percentage inserted into another field BFB:

CCA CCB CCD BFB ID
45 66 3) 100 1
67 36 14) 800 2
86 24 15) 60 5
76 84 0) 100 8
6 55 33) 99 12
......

At the same time, two conditions should be added to judge:
1, three fields the added and >0 data of CCA, CCB, and CCD are calculated: cca+ccb+ccd>0
2, two fields CCA and CCB are added divided by three fields CCA, CCB, and CCD are calculated as a percentage less than the original percentage BFB: and Bfb> ((CCA+CCB)/(CCA+CCB+CCD)) *100

The code is thought of as follows, but error:
[code=php]
Require_once ("header.php");

$obj _db->simplequery ("Update member set bfb= ((CCA+CCB)/(CCA+CCB+CCD) *100 where cca+ccb+ccd>0 and bfb> ((cca+ CCB)/(CCA+CCB+CCD)) *100 ");
?>
[Code]

Please master help correct, thank you!

.
------Solution--------------------
References:
$obj _db->simplequery ("Update member Set Bfb=round (((CCA+CCB)/(CCA+CCB+CCD) *100) where  cca+ccb+ccd>0 and Bfb> ((CCA+CCB)/(CCA+CCB+CCD)) *100 ");

$obj _db->simplequery ("Update member Set Bfb=round (((CCA+CCB)/(CCA+CCB+CCD) *100) where  cca+ccb+ccd>0 and Bfb> ((CCA+CCB)/(CCA+CCB+CCD)) *100 ");
  • 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.