当前位置:网站首页>回复评论的sql
回复评论的sql
2022-07-04 09:32:00 【寒枝不栖sx】
/* Navicat Premium Data Transfer Source Server : 本地 Source Server Type : MySQL Source Server Version : 50536 Source Host : localhost:3306 Source Schema : datamanagement Target Server Type : MySQL Target Server Version : 50536 File Encoding : 65001 Date: 28/06/2022 20:27:33 */
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for class
-- ----------------------------
DROP TABLE IF EXISTS `class`;
CREATE TABLE `class` (
`cno` int(5) NOT NULL AUTO_INCREMENT COMMENT '课程号',
`cname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课程名',
PRIMARY KEY (`cno`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of class
-- ----------------------------
INSERT INTO `class` VALUES (1, '软工1班');
INSERT INTO `class` VALUES (2, '软工2班');
-- ----------------------------
-- Table structure for grade
-- ----------------------------
DROP TABLE IF EXISTS `grade`;
CREATE TABLE `grade` (
`gno` int(5) NOT NULL AUTO_INCREMENT COMMENT '成绩号',
`kno` int(5) NULL DEFAULT NULL COMMENT '课程号',
`sno` int(11) NULL DEFAULT NULL COMMENT '学号',
`grade` int(5) NULL DEFAULT NULL COMMENT '成绩',
PRIMARY KEY (`gno`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 80 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of grade
-- ----------------------------
INSERT INTO `grade` VALUES (7, 1, 3, 61);
INSERT INTO `grade` VALUES (8, 2, 3, 96);
INSERT INTO `grade` VALUES (9, 3, 3, 45);
INSERT INTO `grade` VALUES (10, 1, 4, 69);
INSERT INTO `grade` VALUES (11, 2, 4, 98);
INSERT INTO `grade` VALUES (12, 3, 4, 100);
INSERT INTO `grade` VALUES (13, 1, 5, 63);
INSERT INTO `grade` VALUES (14, 2, 5, 95);
INSERT INTO `grade` VALUES (15, 3, 5, 62);
INSERT INTO `grade` VALUES (16, 1, 6, 46);
INSERT INTO `grade` VALUES (17, 2, 6, 80);
INSERT INTO `grade` VALUES (18, 3, 6, 59);
INSERT INTO `grade` VALUES (22, 1, 8, 55);
INSERT INTO `grade` VALUES (23, 2, 8, 77);
INSERT INTO `grade` VALUES (24, 3, 8, 88);
INSERT INTO `grade` VALUES (25, 1, 9, 65);
INSERT INTO `grade` VALUES (26, 2, 9, 100);
INSERT INTO `grade` VALUES (27, 3, 9, 23);
INSERT INTO `grade` VALUES (28, 1, 10, 56);
INSERT INTO `grade` VALUES (29, 2, 10, 85);
INSERT INTO `grade` VALUES (30, 3, 10, 98);
INSERT INTO `grade` VALUES (31, 1, 11, 45);
INSERT INTO `grade` VALUES (32, 2, 11, 12);
INSERT INTO `grade` VALUES (33, 3, 11, 10);
INSERT INTO `grade` VALUES (34, 1, 12, 48);
INSERT INTO `grade` VALUES (35, 2, 12, 56);
INSERT INTO `grade` VALUES (36, 3, 12, 78);
INSERT INTO `grade` VALUES (37, 1, 13, 68);
INSERT INTO `grade` VALUES (38, 2, 13, 32);
INSERT INTO `grade` VALUES (39, 3, 13, 65);
INSERT INTO `grade` VALUES (40, 1, 14, 98);
INSERT INTO `grade` VALUES (41, 2, 14, 65);
INSERT INTO `grade` VALUES (42, 3, 14, 45);
INSERT INTO `grade` VALUES (44, 1, 16, 92);
INSERT INTO `grade` VALUES (45, 2, 16, 99);
INSERT INTO `grade` VALUES (46, 3, 16, 66);
INSERT INTO `grade` VALUES (47, 1, 17, 96);
INSERT INTO `grade` VALUES (48, 2, 17, 88);
INSERT INTO `grade` VALUES (49, 3, 17, 98);
INSERT INTO `grade` VALUES (50, 1, 18, 85);
INSERT INTO `grade` VALUES (51, 2, 18, 60);
INSERT INTO `grade` VALUES (52, 3, 18, 61);
INSERT INTO `grade` VALUES (59, 1, 21, 68);
INSERT INTO `grade` VALUES (60, 2, 21, 56);
INSERT INTO `grade` VALUES (61, 3, 21, 56);
INSERT INTO `grade` VALUES (62, 1, 22, 65);
INSERT INTO `grade` VALUES (63, 2, 22, 73);
INSERT INTO `grade` VALUES (64, 3, 22, 58);
INSERT INTO `grade` VALUES (65, 1, 23, 56);
INSERT INTO `grade` VALUES (66, 2, 23, 67);
INSERT INTO `grade` VALUES (67, 3, 23, 89);
INSERT INTO `grade` VALUES (71, 1, 25, 65);
INSERT INTO `grade` VALUES (72, 2, 25, 98);
INSERT INTO `grade` VALUES (73, 3, 25, 100);
INSERT INTO `grade` VALUES (74, 1, 26, 3);
INSERT INTO `grade` VALUES (75, 2, 26, 65);
INSERT INTO `grade` VALUES (76, 3, 26, 10);
INSERT INTO `grade` VALUES (77, 1, 27, 60);
INSERT INTO `grade` VALUES (78, 2, 27, 70);
INSERT INTO `grade` VALUES (79, 3, 27, 80);
-- ----------------------------
-- Table structure for kecheng
-- ----------------------------
DROP TABLE IF EXISTS `kecheng`;
CREATE TABLE `kecheng` (
`kno` int(5) NOT NULL AUTO_INCREMENT COMMENT '课程号',
`kname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课程名',
PRIMARY KEY (`kno`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of kecheng
-- ----------------------------
INSERT INTO `kecheng` VALUES (1, '高数');
INSERT INTO `kecheng` VALUES (2, '物理');
INSERT INTO `kecheng` VALUES (3, '英语');
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`rno` int(5) NOT NULL AUTO_INCREMENT COMMENT '角色号',
`rname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色名',
PRIMARY KEY (`rno`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES (1, '学生');
INSERT INTO `role` VALUES (2, '辅导员');
INSERT INTO `role` VALUES (3, '资料管理员');
-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`sno` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`spassword` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '123' COMMENT '密码',
`cno` int(5) NULL DEFAULT NULL COMMENT '班级号',
`sname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
`age` int(3) NULL DEFAULT NULL COMMENT '年龄',
`snative` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '籍贯',
`health` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '健康状态',
`rno` int(5) NULL DEFAULT 1 COMMENT '角色',
`hobby` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '爱好',
`account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学生账号',
PRIMARY KEY (`sno`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES (3, '123', 1, '王五', 22, '湖南株洲', '伤心', 1, '喜欢打游戏', '103');
INSERT INTO `student` VALUES (4, '123', 1, '赵四', 21, '湖南株洲', '健康', 1, '足球', '104');
INSERT INTO `student` VALUES (5, '123', 1, '李五', 22, '湖北武汉', '健康', 1, NULL, '105');
INSERT INTO `student` VALUES (6, '123', 1, '李六', 22, '湖北武汉', '伤心', 1, '踢足球', '106');
INSERT INTO `student` VALUES (8, '123', 1, '李八', 19, '湖南株洲', '开朗', 1, NULL, '108');
INSERT INTO `student` VALUES (9, '123', 1, '李九', 25, '湖南长沙', '开朗', 1, NULL, '109');
INSERT INTO `student` VALUES (10, '123', 1, '李十', 26, '湖南长沙', '伤心', 1, NULL, '110');
INSERT INTO `student` VALUES (11, '123', 1, '李十一', 24, '湖南长沙', '开朗', 1, NULL, '111');
INSERT INTO `student` VALUES (12, '123', 1, '李十二', 24, '湖南长沙', '开朗', 1, NULL, '112');
INSERT INTO `student` VALUES (13, '123', 1, '李十三', 23, '湖南长沙', '伤心', 1, NULL, '113');
INSERT INTO `student` VALUES (14, '123', 1, '李十四', 24, '湖南长沙', '健康', 1, NULL, '114');
INSERT INTO `student` VALUES (15, '123', 2, '李十五', 22, NULL, NULL, 1, NULL, '115');
INSERT INTO `student` VALUES (16, '123', 2, '黄行', 21, '湖南怀化', '开心', 1, '看书', '116');
INSERT INTO `student` VALUES (17, '123', 1, '欧阳卡卡', NULL, NULL, NULL, 1, NULL, '117');
INSERT INTO `student` VALUES (18, '123', 2, '周小胖', NULL, NULL, NULL, 1, NULL, '118');
INSERT INTO `student` VALUES (21, '123', 2, '白系', NULL, NULL, NULL, 1, NULL, '121');
INSERT INTO `student` VALUES (22, '123', 1, '大苏打', NULL, NULL, NULL, 1, NULL, '122');
INSERT INTO `student` VALUES (23, '123', 1, '撒旦', NULL, NULL, NULL, 1, NULL, '123');
INSERT INTO `student` VALUES (25, '123', 1, '测试', NULL, NULL, NULL, 1, NULL, '125');
INSERT INTO `student` VALUES (26, '123', 1, 'cedshi', NULL, NULL, NULL, 1, NULL, '126');
INSERT INTO `student` VALUES (27, '123', 1, '小明', NULL, NULL, NULL, 1, NULL, '127');
-- ----------------------------
-- Table structure for teacher
-- ----------------------------
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher` (
`tno` int(5) NOT NULL COMMENT '教师号',
`account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '教师账户',
`tpassword` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '教师密码',
`tname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '教师姓名',
`cno` int(5) NULL DEFAULT NULL COMMENT '班级号',
`rno` int(5) NULL DEFAULT NULL COMMENT '角色号',
PRIMARY KEY (`tno`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of teacher
-- ----------------------------
INSERT INTO `teacher` VALUES (1, '1001', '123', '王辅导员', 1, 2);
INSERT INTO `teacher` VALUES (2, '1002', '123', '李辅导员', 2, 2);
INSERT INTO `teacher` VALUES (3, 'admin', 'admin', '资料管理员', NULL, 3);
SET FOREIGN_KEY_CHECKS = 1;
查询语句:
SELECT s.sno,s.spassword,s.sname,c.cname,s.age,s.snative,s.health,s.hobby,r.rname,
SUM(case when k.kname='高数' then g.grade end ) as '高数',
SUM(case when k.kname='物理' then g.grade end ) as '物理',
SUM(case when k.kname='英语' then g.grade end ) as '英语'
from class c,grade g,kecheng k,student s,role r
where s.sno=g.sno and g.kno=k.kno and s.cno=c.cno and r.rno=s.rno GROUP BY sno;
结果图
边栏推荐
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
- There are 100 people eating 100 apples, one adult eating 4 apples, and four children eating 1 apple. How can they eat exactly 100 apples? Use any high-level language you are familiar with
- C language - Introduction - Foundation - syntax - [operators, type conversion] (6)
- 2022-2028 global protein confectionery industry research and trend analysis report
- Awk from digging into the ground to getting started (10) awk built-in functions
- Awk from entry to earth (14) awk output redirection
- 2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
- Lauchpad X | 模式
- What is uid? What is auth? What is a verifier?
- C language - Introduction - Foundation - syntax - [identifier, keyword, semicolon, space, comment, input and output] (III)
猜你喜欢
C language - Introduction - Foundation - syntax - data type (4)
Target detection -- intensive reading of yolov3 paper
2022-2028 global intelligent interactive tablet industry research and trend analysis report
After unplugging the network cable, does the original TCP connection still exist?
Jianzhi offer 09 realizes queue with two stacks
Svg image quoted from CodeChina
2022-2028 global optical transparency industry research and trend analysis report
Latex download installation record
2022-2028 global visual quality analyzer industry research and trend analysis report
2022-2028 global edible probiotic raw material industry research and trend analysis report
随机推荐
After unplugging the network cable, does the original TCP connection still exist?
Development trend and market demand analysis report of high purity tin chloride in the world and China Ⓔ 2022 ~ 2027
How to display √ 2 on the command line terminal ̅? This is actually a blog's Unicode test article
Ultimate bug finding method - two points
AMLOGIC gsensor debugging
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
Daughter love in lunch box
Global and Chinese trisodium bicarbonate operation mode and future development forecast report Ⓢ 2022 ~ 2027
Write a jison parser from scratch (1/10):jison, not JSON
China electronic grade sulfur trioxide Market Forecast and investment strategy report (2022 Edition)
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
Are there any principal guaranteed financial products in 2022?
《网络是怎么样连接的》读书笔记 - 认识网络基础概念(一)
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
保姆级JDEC增删改查练习
Langage C - démarrer - base - syntaxe - [opérateur, conversion de type] (vi)
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
There are 100 people eating 100 apples, one adult eating 4 apples, and four children eating 1 apple. How can they eat exactly 100 apples? Use any high-level language you are familiar with
Luogu deep foundation part 1 Introduction to language Chapter 4 loop structure programming (2022.02.14)
Explain TCP protocol in detail three handshakes and four waves