For example, there are several data in the database that want to add and insert two fields from each piece of data 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
......
The single calculation is 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 at once? Please give the 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 '");
Praise..
$obj _db->simplequery ("Update member set CCD=CCA+CCB");
$obj _db->simplequery ("Update member set CCD=CCA+CCB");
This is the landlord's request, the whole table once done
This is the standard SQL Ah, and PHP is OK. Grammer:update TableName Set cloum= "where".
$obj _db->simplequery ("Update member set CCD=CCA+CCB");
Thank you very much! Please continue to ask:
If you want to judge the cca+ccb>110 of the calculation, how to write this wrong AH:
$obj _db->simplequery ("Update member set CCD=CCA+CCB where SUM (CCA+CCB) >110");
Please help 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