In one of the database table below
Goal fumble GD
10 20-10
45 16 29
6 3 3
22 13
36 19
The first three lines of GD data is manually fill myself, but the amount of data is too big, want to help you, how to use SQL to achieve with a "goal" minus "fumble
"And the results automatically fill to "GD" column, as Excel spreadsheets,
Or not limited to SQL statements,, what method can help the younger brother to efficiently finish the homework,
Thanked you bosses in advance,
CodePudding user response:
It is ok to use the updateCodePudding user response:
Skybright123 bosses: hello, thank you for your advice, but the update need every time I try to fill a good goal and fumble after implementation can fill again, is there a goal that I updated in real time database and fumble difference can spread to GD, real-time and display the way? thank youCodePudding user response:
Written statements directly can, need not query GD field,The SELECT goal, fumble, goal - fumble GD the FROM name of the table;
CodePudding user response:
If you are using mysql5.7 and its later version, build table set for calculating column GD column, after just goal and fumble field insert data, GD fields in the query will be automatically calculatedThe create table TableName
(
Goal int (11),
Fumble int (11),
GD int (11) as (goal - fumbel)
)