Phpmysql summation statement. Php Tutorial mysql tutorial summation statement automatically calculates the value of two fields and assigns it to another field SQL $ sqlupdatetablesetsummathe + language; calculates the total data of one field column $ sqlse php Tutorial mysql tutorial summation statement
// Automatically calculate the values of the two fields and assign them to another SQL field
$ SQL = "update table set sum = mathe + language ";
// Calculate the total data of a field column
$ SQL = "select sum (sum) from tables ";
// Let's look at an instance.
/*
Create a table
Create table 'CC'. 'sumtable '(
'Id' INT (4) not null,
'A1' INT (4) not null,
'A2 'INT (4) not null,
'Summ' INT (8) NOT NULL
) ENGINE = InnoDB
Insert record
Insert into 'CC'. 'sumtable '(
'Id ',
'A1 ',
'A2 ',
'Summ'
)
VALUES (
'1', '5', '5', '0'
),(
'2', '6', '5', '0'
);
*/
// Automatically calculate the values of the two fields and assign them to another SQL field
Update sumtable set summ = a1 + a2
// Sum
SELECT sum (summ) FROM sumtable
Sum (summ)
21
// Source www. bKjia. c0m
In the mysql tutorial, the sum statement // automatically calculates the values of the two fields and assigns them to another field. SQL $ SQL = update table set sum = mathe + language; // calculate the total data of a field column $ SQL = se...