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 ");