Home > database >  View of the problem
View of the problem

Time:10-02

/* create student data tables in the database mydb,
Table has id, name (student's name), math (math), Chinese (Chinese)
And English (English) fields,
View, and then create a view view_score, contain math, Chinese, English and total (total score) fields, */
/* solve MSQL views do not use the aggregate function of small problems, */
/* code below */

Use mydb;
/* create the student table */
The create table student (
Id int PRIMARY KEY auto_increment comment 'id',
The name varchar (10) not null comment 'student's name,
Math DECIMAL (4, 1) not null comment 'math scores,
Chinese DECIMAL (4, 1) not null comment 'language result,
English a DECIMAL (4, 1) not null comment 'English'
) the DEFAULT CHARSET=utf8;
/* create a view view_score */
The create view view_score AS
The select math, Chinese, English, math, Chinese and English total from student;
  • Related