From f808f17eba664938a73edb448b9f202311d0c14f Mon Sep 17 00:00:00 2001 From: liuyibo <14460729+liuyibo12345@user.noreply.gitee.com> Date: Thu, 18 Jul 2024 20:46:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=80=83=207.18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 38 +++++++++++++++++ pom.xml | 17 ++++++++ sql/a.sql | 103 +++++++++++++++++++++++++++++++++++++++++++++++ sql/g6rk7_18.sql | 66 ++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 sql/a.sql create mode 100644 sql/g6rk7_18.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac288aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/ +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..349bb2a --- /dev/null +++ b/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.bwie + day01 + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + diff --git a/sql/a.sql b/sql/a.sql new file mode 100644 index 0000000..b8f6e9b --- /dev/null +++ b/sql/a.sql @@ -0,0 +1,103 @@ +create table student( +eid int(11) auto_increment primary key , +ename varchar(40), +sex varchar(10), +tel varchar(50), +class_id int(11) , +age int(11), +sal int(2) +) + + +insert into student(ename,sex,tel,class_id,age,sal) values + ('小红','女','16738192312','1','25','3000'), + ('小蓝','男','17863123412','2','10','1000'), + ('小绿','女','16234231124','2','25','2000'), + ('小黄','男','16867454532','1','25','8000') + + + insert into student(ename,sex,tel,class_id,age,sal) values + ('小博','男','17639414630','1','50','10000') + + + + #2.查询所有学生信息,并根据年龄进行降序排序。(10分) + +SELECT + * +FROM + student + LEFT JOIN class ON class.class_id = student.class_id +ORDER BY + student.age DESC + + + #3.显示姓王的学生的详细信息。(10分) +SELECT + * +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.ename like ('%王%') + + + #4.查询工资大于5000的所有男同学的信息。(10分) + + SELECT + * +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.sal > 5000 + + #5.查询班级编号为20的男同学的电话号码。(10分) + SELECT + student.tel +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.class_id = 20 + and student.sex = '男' + + + +#6.查询最低工资。(10分) +SELECT + student.sal +FROM + student +ORDER BY + student.sal + LIMIT 1 + +#7.查询班级为30的学生的最小年龄。(10分) + + SELECT + * +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.class_id = 20 + ORDER BY student.age limit 1 + + + #8.查询女生的最低工资。(15分) + +SELECT + student.sal +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.sex = '女' ORDER BY student.sal limit 1 + + #9.查询女学生中薪资最低的人的全部信息。(15分) + +SELECT + * +FROM + student + LEFT JOIN class ON class.class_id = student.class_id + where student.sex = '女' ORDER BY student.sal limit 1 + + + \ No newline at end of file diff --git a/sql/g6rk7_18.sql b/sql/g6rk7_18.sql new file mode 100644 index 0000000..c555055 --- /dev/null +++ b/sql/g6rk7_18.sql @@ -0,0 +1,66 @@ +/* + Navicat Premium Data Transfer + + Source Server : 116.198.196.184 + Source Server Type : MySQL + Source Server Version : 50736 + Source Host : 116.198.196.184:3306 + Source Schema : g6rk7_18 + + Target Server Type : MySQL + Target Server Version : 50736 + File Encoding : 65001 + + Date: 18/07/2024 08:56:20 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for class +-- ---------------------------- +DROP TABLE IF EXISTS `class`; +CREATE TABLE `class` ( + `class_id` int(11) NOT NULL AUTO_INCREMENT, + `class_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`class_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of class +-- ---------------------------- +INSERT INTO `class` VALUES (1, '1班'); +INSERT INTO `class` VALUES (2, '2班'); +INSERT INTO `class` VALUES (20, '20班'); +INSERT INTO `class` VALUES (30, '30班'); + +-- ---------------------------- +-- Table structure for student +-- ---------------------------- +DROP TABLE IF EXISTS `student`; +CREATE TABLE `student` ( + `eid` int(11) NOT NULL AUTO_INCREMENT, + `ename` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `sex` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `tel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `class_id` int(11) NULL DEFAULT NULL, + `age` int(11) NULL DEFAULT NULL, + `sal` int(2) NULL DEFAULT NULL, + PRIMARY KEY (`eid`) USING BTREE, + INDEX `class_id`(`class_id`) USING BTREE, + CONSTRAINT `student_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `class` (`class_id`) ON DELETE RESTRICT ON UPDATE RESTRICT +) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of student +-- ---------------------------- +INSERT INTO `student` VALUES (1, '小红', '女', '16738192312', 1, 25, 3000); +INSERT INTO `student` VALUES (2, '小蓝', '男', '1786312341230', 30, 10, 1000); +INSERT INTO `student` VALUES (3, '小绿', '女', '16234231124', 30, 25, 2000); +INSERT INTO `student` VALUES (4, '王黄', '男', '16867454532', 20, 25, 8000); +INSERT INTO `student` VALUES (5, '小博', '男', '17639414630', 1, 50, 10000); +INSERT INTO `student` VALUES (6, '小嘻嘻', '男', '12345678654', 20, 33, 3444); +INSERT INTO `student` VALUES (7, '大嘻嘻', '女', '76543234561', 20, 33, 3333); + +SET FOREIGN_KEY_CHECKS = 1;