mysql现查询所有同学的Sno、Cno和rank列,写出查询 报错,希望有人可以解决一下,


# mysql
DROP TABLE IF EXISTS `score`;
CREATE TABLE `score`  (
  `Sno` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '学号',
  `Cno` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '课程号',
  `Degree` decimal(10, 0) NULL DEFAULT NULL COMMENT '成绩'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of score
-- ----------------------------
INSERT INTO `score` VALUES ('200215121', 'cs-201', 92);
INSERT INTO `score` VALUES ('200215121', 'ma-202', 85);
INSERT INTO `score` VALUES ('200215121', 'cs-207', 93);
INSERT INTO `score` VALUES ('200215125', 'ee-203', 99);
INSERT INTO `score` VALUES ('200215125', 'ee-208', 99);
INSERT INTO `score` VALUES ('200215125', 'ee-210', 68);
INSERT INTO `score` VALUES ('200215122', 'ee-203', 88);
INSERT INTO `score` VALUES ('200215122', 'ee-204', 67);
INSERT INTO `score` VALUES ('200215122', 'cs-201', 79);
INSERT INTO `score` VALUES ('200215123', 'cs-201', 69);
INSERT INTO `score` VALUES ('200215123', 'cs-209', 88);
INSERT INTO `score` VALUES ('200215123', 'ee-210', 72);
INSERT INTO `score` VALUES ('200215127', 'cs-201', 69);
INSERT INTO `score` VALUES ('200215127', 'ee-204', 85);
INSERT INTO `score` VALUES ('200215127', 'cs-206', 98);

SET FOREIGN_KEY_CHECKS = 1;

DROP TABLE IF EXISTS `grade`;
CREATE TABLE `grade`  (
  `low` int(11) NULL DEFAULT NULL,
  `upp` int(11) NULL DEFAULT NULL,
  `rank` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

现查询所有同学的Sno、Cno和rank列。
SQL如下
select sno,cno,rank
from score inner join grade
on(score.degree>=grade.low and score.degree<=grade.upp)
order by sno;

grade.rank

报错信息如下,

select sno,cno,rank
from score inner join grade
on(score.degree>=grade.low and score.degree<=grade.upp)
order by sno
> 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from score inner join grade
on(score.degree>=grade.low and score.degree<=grade.' at line 2
> 时间: 0s