Database structure
And I want to make the same person's different grades into this person. displayed on different columns of this line, this time divided into 2 shows:
The first shows----"Multiple rows to one column" (the merged data is on the same column):
SQL is as follows:
The second shows----"Multiline multiple Columns" (the merged data is on different columns):
SQL is as follows:
SELECT name, MAX (case type when ' math ' then score else 0 end) Math,max (case Type "English" then score else 0 end) 中文版 , MAX (case Type "language" then score ELSE 0 END) Chinese from Stu GROUP by name
-----------------------------------------------------------------------------------------------------Cute Split-line-------------- --------------------------------------------------------------------------------------
Of course, in the first case (shown in a column), there are some other similar forms:
Form one:
SQL is as follows:
Select Name, Group_concat (type, ' fractions: ', score
Hehe, of course, if you are familiar with the usage of Group_concat and concat, you also make the following form:
Its SQL is as follows:
Select Name, concat (name, ' The score is [', Group_concat (type, ' fraction: ', score
MySQL row variable column (multiple rows become one row/multiple rows merged into one row/multiple rows merged into multiple columns/merged rows)