时间:2021-07-01 10:21:17 帮助过:7人阅读
CREATE TABLE `TEST_TB_GRADE2` ( `ID` int(10) NOT NULL AUTO_INCREMENT, `USER_NAME` varchar(20) DEFAULT NULL, `CN_SCORE` float DEFAULT NULL, `MATH_SCORE` float DEFAULT NULL, `EN_SCORE` float DEFAULT ‘0‘, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; insert into TEST_TB_GRADE2(USER_NAME, CN_SCORE, MATH_SCORE, EN_SCORE) values ("张三", 34, 58, 58), ("李四", 45, 87, 45), ("王五", 76, 34, 89);
select user_name, ‘语文‘ COURSE , CN_SCORE as SCORE from test_tb_grade2 union select user_name, ‘数学‘ COURSE, MATH_SCORE as SCORE from test_tb_grade2 union select user_name, ‘英语‘ COURSE, EN_SCORE as SCORE from test_tb_grade2 order by user_name,COURSE;
MySQL查询结果行转列、列转行
标签:engine prim nio insert key mic def set mysq