How to count the sum of all the data in a certain field in the table, and how to output the result?
Thanks for the invitation
$updataquery = "select sum(lv) AS the_result from gti_enews_technology_group" ; $r=$empire->fetch1($updataquery); print_r($r); //打印的结果是Array ( [0] => 252 [the_result] => 252 ) 打印看看是什么就好处理了
If it is MySQL, there are built-in functions directlySUM:
SUM
SELECT SUM(column) FROM table WHERE conditions;
Reference https://dev.mysql.com/doc/ref...
If you directly use SQL statements to sum, it is not good if the data volume is large. Therefore, it is better to take out the value of this field first. If the amount of data is large, sum it up piece by piece and then integrate it.
Thanks for the invitation
If it is MySQL, there are built-in functions directly
SUM
:Reference https://dev.mysql.com/doc/ref...
If you directly use SQL statements to sum, it is not good if the data volume is large. Therefore, it is better to take out the value of this field first. If the amount of data is large, sum it up piece by piece and then integrate it.