Java基础入门day39

day39

DQL

查询结果去重

语法:

distinct 列明

select distinct sex from tb_stu;        //  性别去重,最终只保留两个结果boy和girl
select distinct name, sex from tb_stu;  //  姓名和性别同时去重,sex部分字段值相同,不能去重,去重只能是所有字段都相同才可以实现去重效果,只有                                          //      name和sex都相同才会实现去重效果
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
+------+--------------+------+------+-------+------+
3 rows in set (0.01 sec)
​
mysql> select sex from tb_stu;
+------+
| sex  |
+------+
| boy  |
| girl |
| girl |
+------+
3 rows in set (0.00 sec)
​
mysql> select distinct sex from tb_stu;
+------+
| sex  |
+------+
| boy  |
| girl |
+------+
2 rows in set (0.00 sec)
​
mysql> select name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)
​
mysql> select distinct name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)
​
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)
​
mysql> insert into tb_stu values(9530, 'qiuxiang', 'girl', 110, 80, 18);
Query OK, 1 row affected (0.01 sec)
​
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)
​
mysql> select name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
| qiuxiang     | girl |
+--------------+------+
4 rows in set (0.00 sec)
​
mysql> select distinct name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)

排序

语法:

select 列名 from 表名 order by 排序列 [排序规则]

单列排序

select * from tb_stu order by score;                //  根据成绩来排序,默认排序规则是升序排列 
select * from tb_stu order by score asc;            //  asc是升序关键字,默认就是升序,可以不写
select * from tb_stu order by score desc;           //  desc降序排序的关键字
排序规则描述
asc对前面排序列做升序排序,也是默认值
desc对前面排序列做降序排列

多列排序

select * from tb_stu order by sex desc, score;
select * from tb_stu order by sex desc, score asc;
select * from tb_stu order by sex desc, score desc;
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex asc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex desc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex desc, score;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex desc, score desc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
​
mysql> select * from tb_stu order by sex desc, score asc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

条件查询

语法:
​
select 列名 from 表名 where 条件
关键字描述
where条件在查询结果中,筛选符合条件的查询结果,条件为布尔表达式
  • 等值判断

select * from tb_stu where age = 30;        //  查询age为30的学生
注意: 与Java的==不同,mysql中等值判断使用=
  • 逻辑判断(and or not)

select * from tb_stu where age = 30 and sex = 'girl';			//	and表示交集,得同时满足,查询age为30并且sex同时为girl结果
select * from tb_stu where age = 30 or sex = 'girl';			//	or表示并集,任何条件满足都可以,查询age为30或者sex为girl的所有结果
select * from tb_stu where not age = 30;						//	not取反,对于现有结果取反操作,年龄不为30的所有结果
mysql> select * from tb_stu where age = 30 and sex = 'girl';
+------+--------+------+------+-------+------+
| sid  | name   | sex  | tel  | score | age  |
+------+--------+------+------+-------+------+
| 9529 | shiliu | girl | 114  |    59 |   30 |
+------+--------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where age = 30 or sex = 'girl';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9529 | shiliu   | girl | 114  |    59 |   30 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where not age = 30;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)
  • 不等值判断(> >= < <= != <>)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where sex < 60;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set, 5 warnings (0.00 sec)

mysql> select * from tb_stu where score < 60;
+------+--------+------+------+-------+------+
| sid  | name   | sex  | tel  | score | age  |
+------+--------+------+------+-------+------+
| 9529 | shiliu | girl | 114  |    59 |   30 |
+------+--------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where score >= 60;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where score = 100;
Empty set (0.00 sec)

mysql> select * from tb_stu where score != 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where score <> 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)
mysql> select * from tb_stu where score <= 100 and score >= 80;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)
  • 区间判断(between and)

mysql> select * from tb_stu where score between 60 and 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 80 and 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 80 and 99;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 180 and 99;
Empty set (0.00 sec)

注意:在区间判断的语法中,小值在前,大值在后,反之将得不到结果

  • null值判断(is null, is not null)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select * from tb_stu where name is null;
Empty set (0.00 sec)

mysql> select * from tb_stu where sex is null;
+------+-----------+------+------+-------+------+
| sid  | name      | sex  | tel  | score | age  |
+------+-----------+------+------+-------+------+
| 9532 | chunxiang | NULL | NULL |  NULL | NULL |
+------+-----------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where sex is not null;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

判断某个字段是否为空,或者是否不为空

  • 枚举查询(in(值1, 值2, ...))

select * from tb_stu where sid in (9527, 9528, 9599);			//	查询sid分别为9527, 9528和9599的值,9599不存在,则不显示,也不报																  //		错,只列出9527 和9528的值

注意:in的查询效率较低,可以通过多条件拼接

  • 模糊查询 like

like _(单个字符)

like %(任意长度的字符)
select * from tb_stu where name like '%ng'						//	查询name以ng结尾的所有结果
select * from tb_stu where name like '_ng'						//	查询name以ng结尾,并且ng前面只有一个字符的结果
select * from tb_stu where name like 'xiang'					//	查询name跟xiang相像的结果,没有使用任何通配符,类似于等值查询
select * from tb_stu where name like '___xiang'					//	查询name以xiang结尾,并且xiang之前由三个字符
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '%ng';
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '_ng';
Empty set (0.00 sec)

mysql> select * from tb_stu where name like 'qiuxiang';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
2 rows in set (0.00 sec)

mysql> select * from tb_stu where name like 'xiang';
Empty set (0.00 sec)

mysql> select * from tb_stu where name like '___xiang';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
2 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '____xiang';
+------+-----------+------+------+-------+------+
| sid  | name      | sex  | tel  | score | age  |
+------+-----------+------+------+-------+------+
| 9532 | chunxiang | NULL | NULL |  NULL | NULL |
+------+-----------+------+------+-------+------+
1 row in set (0.00 sec)

注意:

%代表任意长度字符

_代表任意的单个字符

没有任何通配符,即使使用like也与等值查询效果一致

  • 分支结构查询

基本语法:
case 
when 条件1 then 结果1
when 条件2 then 结果2
when 条件3 then 结果3
else 结果n
end
select sid, name, 
	case 
		when score >= 90 then 'A' 
		when score >= 80 then 'B'
		when score >= 70 then 'C'
		when score >= 60 then 'D'
		else 'E'
		end
from tb_stu;
select sid, name, 
	case 
		when score >= 90 then 'A' 
		when score >= 80 then 'B'
		when score >= 70 then 'C'
		when score >= 60 then 'D'
		else 'E'
		end as 'level'
from tb_stu;

时间查询

语法:

select 时间函数(参数列表)
执行时间函数,会自动生成一张虚拟表,一行一列
时间函数描述
now()当前系统时间(y M d h m s),不是所有的版本都支持
sysdate()当前系统时间(y M d h m s)
curdate()当前的日期
curtime()当前时间
week(date)当前日期是一年中的第几周
year(date)获取指定日期的年份
hour(date)获取指定时间的小时值
minute(date)获取指定时间的分钟值
adddate(date, n)计算指定date加上n天后的值,n也可以为负值
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2024-04-24 11:21:05 |
+---------------------+
1 row in set (0.00 sec)

mysql> select database();
+------------+
| database() |
+------------+
| saas       |
+------------+
1 row in set (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2024-04-24 11:36:28 |
+---------------------+
1 row in set (0.00 sec)

mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2024-04-24 11:38:30 |
+---------------------+
1 row in set (0.00 sec)

mysql> select curdate();
+------------+
| curdate()  |
+------------+
| 2024-04-24 |
+------------+
1 row in set (0.00 sec)

mysql> select curtiem();
ERROR 1305 (42000): FUNCTION saas.curtiem does not exist
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 11:39:30  |
+-----------+
1 row in set (0.00 sec)

mysql> select week(now());
+-------------+
| week(now()) |
+-------------+
|          16 |
+-------------+
1 row in set (0.00 sec)

mysql> select year(now());
+-------------+
| year(now()) |
+-------------+
|        2024 |
+-------------+
1 row in set (0.00 sec)

mysql> select hour(now());
+-------------+
| hour(now()) |
+-------------+
|          11 |
+-------------+
1 row in set (0.00 sec)

mysql> select minute(now());
+---------------+
| minute(now()) |
+---------------+
|            42 |
+---------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), 5)
 -> ;
+---------------------+
| adddate(now(), 5)   |
+---------------------+
| 2024-04-29 11:42:47 |
+---------------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), 8);
+---------------------+
| adddate(now(), 8)   |
+---------------------+
| 2024-05-02 11:43:17 |
+---------------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), -8);
+---------------------+
| adddate(now(), -8)  |
+---------------------+
| 2024-04-16 11:43:45 |
+---------------------+
1 row in set (0.00 sec)

字符串查询

语法:
select 字符串函数
字符串函数描述
concat(str1, str2, .. )将多个字符串拼接
insert(str, pos, len, newStr)将str中指定pos位置开始len个长度的内容替换为newStr
lower(str)将指定字符串转换为小写
upper(str)将指定的字符串转换为大写
substring(str, num, len)将str字符串指定num位置开始截取len个内容
mysql> select concat("hello", "world");
+--------------------------+
| concat("hello", "world") |
+--------------------------+
| helloworld               |
+--------------------------+
1 row in set (0.00 sec)

mysql> select concat("hello", "world", "saas");
+----------------------------------+
| concat("hello", "world", "saas") |
+----------------------------------+
| helloworldsaas                   |
+----------------------------------+
1 row in set (0.00 sec)

mysql> select concat("My", "SQL");
+---------------------+
| concat("My", "SQL") |
+---------------------+
| MySQL               |
+---------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 0, "MySQL");
+-----------------------------------------+
| insert("这是一个数据库", 3, 0, "MySQL") |
+-----------------------------------------+
| 这是MySQL一个数据库                     |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 2, "MySQL");
+-----------------------------------------+
| insert("这是一个数据库", 3, 2, "MySQL") |
+-----------------------------------------+
| 这是MySQL数据库                         |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 2, "关系");
+----------------------------------------+
| insert("这是一个数据库", 3, 2, "关系") |
+----------------------------------------+
| 这是关系数据库                         |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 0, "关系");
+----------------------------------------+
| insert("这是一个数据库", 3, 0, "关系") |
+----------------------------------------+
| 这是关系一个数据库                     |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 5, 0, "关系");
+----------------------------------------+
| insert("这是一个数据库", 5, 0, "关系") |
+----------------------------------------+
| 这是一个关系数据库                     |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select lower("MySQL");
+----------------+
| lower("MySQL") |
+----------------+
| mysql          |
+----------------+
1 row in set (0.00 sec)

mysql> select upper("MySQL");
+----------------+
| upper("MySQL") |
+----------------+
| MYSQL          |
+----------------+
1 row in set (0.00 sec)

mysql> select substring("javaMySQLOracle", 5, 5)
 -> ;
+------------------------------------+
| substring("javaMySQLOracle", 5, 5) |
+------------------------------------+
| MySQL                              |
+------------------------------------+
1 row in set (0.00 sec)

聚合函数

语法:

select 聚合函数() from 表名
聚合函数描述
count()求总行数
max()求最大值
min()求最小值
sum()求和
avg()求平均值
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select count(*) from tb_stu;
+----------+
| count(*) |
+----------+
|        6 |
+----------+
1 row in set (0.00 sec)

mysql> select count(sid) from tb_stu;
+------------+
| count(sid) |
+------------+
|          6 |
+------------+
1 row in set (0.00 sec)

mysql> select count(1) from tb_stu;
+----------+
| count(1) |
+----------+
|        6 |
+----------+
1 row in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select max(score) from tb_stu;
+------------+
| max(score) |
+------------+
|         99 |
+------------+
1 row in set (0.00 sec)

mysql> select min(score) from tb_stu;
+------------+
| min(score) |
+------------+
|         59 |
+------------+
1 row in set (0.00 sec)

mysql> select sum(score) from tb_stu;
+------------+
| sum(score) |
+------------+
|        395 |
+------------+
1 row in set (0.00 sec)

mysql> select avg(score) from tb_stu;
+------------+
| avg(score) |
+------------+
|         79 |
+------------+
1 row in set (0.00 sec)

注意:聚合函数自动忽略null值,所有的null将不进行统计

分组查询

语法:

select 列名 form表名 where 条件 group by 分组依据

group by根据指定分组依据进行分组

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select max(score) from tb_stu;
+------------+
| max(score) |
+------------+
|         99 |
+------------+
1 row in set (0.00 sec)

mysql> select max(score) from tb_stu group by sex;
+------------+
| max(score) |
+------------+
|       NULL |
|         99 |
|         80 |
+------------+
3 rows in set (0.00 sec)

mysql> select min(score) from tb_stu group by sex;
+------------+
| min(score) |
+------------+
|       NULL |
|         77 |
|         59 |
+------------+
3 rows in set (0.00 sec)

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.43-log MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use saas;
Database changed
mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
+------+--------------+------+------+-------+------+
3 rows in set (0.01 sec)

mysql> select sex from tb_stu;
+------+
| sex  |
+------+
| boy  |
| girl |
| girl |
+------+
3 rows in set (0.00 sec)

mysql> select distinct sex from tb_stu;
+------+
| sex  |
+------+
| boy  |
| girl |
+------+
2 rows in set (0.00 sec)

mysql> select name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)

mysql> select distinct name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> insert into tb_stu values(9530, 'qiuxiang', 'girl', 110, 80, 18);
Query OK, 1 row affected (0.01 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
| qiuxiang     | girl |
+--------------+------+
4 rows in set (0.00 sec)

mysql> select distinct name, sex from tb_stu;
+--------------+------+
| name         | sex  |
+--------------+------+
| zhouxingxing | boy  |
| qiuxiang     | girl |
| shiliu       | girl |
+--------------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu order by score;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu order by score asc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu order by score desc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> insert into tb_stu values(9531, 'zhuzhishan', 'boy', '112', 77, 22);
Query OK, 1 row affected (0.01 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex asc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex desc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex desc, score;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex desc, score desc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu order by sex desc, score asc;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where age = 30;
+------+--------+------+------+-------+------+
| sid  | name   | sex  | tel  | score | age  |
+------+--------+------+------+-------+------+
| 9529 | shiliu | girl | 114  |    59 |   30 |
+------+--------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where age = 30 and sex = 'girl';
+------+--------+------+------+-------+------+
| sid  | name   | sex  | tel  | score | age  |
+------+--------+------+------+-------+------+
| 9529 | shiliu | girl | 114  |    59 |   30 |
+------+--------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where age = 30 or sex = 'girl';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9529 | shiliu   | girl | 114  |    59 |   30 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where not age = 30;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where sex < 60;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set, 5 warnings (0.00 sec)

mysql> select * from tb_stu where score < 60;
+------+--------+------+------+-------+------+
| sid  | name   | sex  | tel  | score | age  |
+------+--------+------+------+-------+------+
| 9529 | shiliu | girl | 114  |    59 |   30 |
+------+--------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where score >= 60;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where score = 100;
Empty set (0.00 sec)

mysql> select * from tb_stu where score != 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where score <> 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu where score <= 100 and score >= 80;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 60 and 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 80 and 100;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 80 and 99;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
3 rows in set (0.00 sec)

mysql> select * from tb_stu where score between 180 and 99;
Empty set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> insert into tb_stu (sid, name) values(9532, 'chunxiang');
Query OK, 1 row affected (0.02 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select * from tb_stu where name is null;
Empty set (0.00 sec)

mysql> select * from tb_stu where sex is null;
+------+-----------+------+------+-------+------+
| sid  | name      | sex  | tel  | score | age  |
+------+-----------+------+------+-------+------+
| 9532 | chunxiang | NULL | NULL |  NULL | NULL |
+------+-----------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu where sex is not null;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
+------+--------------+------+------+-------+------+
5 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select * from tb_stu where sid in (9527, 9528, 9599);
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
+------+--------------+------+------+-------+------+
2 rows in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '%ng';
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
4 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '_ng';
Empty set (0.00 sec)

mysql> select * from tb_stu where name like 'qiuxiang';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
2 rows in set (0.00 sec)

mysql> select * from tb_stu where name like 'xiang';
Empty set (0.00 sec)

mysql> select * from tb_stu where name like '___xiang';
+------+----------+------+------+-------+------+
| sid  | name     | sex  | tel  | score | age  |
+------+----------+------+------+-------+------+
| 9528 | qiuxiang | girl | 110  |    80 |   18 |
| 9530 | qiuxiang | girl | 110  |    80 |   18 |
+------+----------+------+------+-------+------+
2 rows in set (0.00 sec)

mysql> select * from tb_stu where name like '____xiang';
+------+-----------+------+------+-------+------+
| sid  | name      | sex  | tel  | score | age  |
+------+-----------+------+------+-------+------+
| 9532 | chunxiang | NULL | NULL |  NULL | NULL |
+------+-----------+------+------+-------+------+
1 row in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select sid, name,
 ->  case
 ->          when score >= 90 then 'A'
 ->          when score >= 80 then 'B'
 ->          when score >= 70 then 'C'
 ->          when score >= 60 then 'D'
 ->          else 'E'
 ->          end
 -> from tb_stu;
+------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| sid  | name         | case
             when score >= 90 then 'A'
             when score >= 80 then 'B'
             when score >= 70 then 'C'
             when score >= 60 then 'D'
             else 'E'
             end |
+------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| 9527 | zhouxingxing | A
                                     |
| 9528 | qiuxiang     | B
                                     |
| 9529 | shiliu       | E
                                     |
| 9530 | qiuxiang     | B
                                     |
| 9531 | zhuzhishan   | C
                                     |
| 9532 | chunxiang    | E
                                     |
+------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------+
6 rows in set (0.00 sec)

mysql> select sid, name,
 ->  case
 ->          when score >= 90 then 'A'
 ->          when score >= 80 then 'B'
 ->          when score >= 70 then 'C'
 ->          when score >= 60 then 'D'
 ->          else 'E'
 ->          end as 'level'
 -> from tb_stu;
+------+--------------+-------+
| sid  | name         | level |
+------+--------------+-------+
| 9527 | zhouxingxing | A     |
| 9528 | qiuxiang     | B     |
| 9529 | shiliu       | E     |
| 9530 | qiuxiang     | B     |
| 9531 | zhuzhishan   | C     |
| 9532 | chunxiang    | E     |
+------+--------------+-------+
6 rows in set (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2024-04-24 11:21:05 |
+---------------------+
1 row in set (0.00 sec)

mysql> select database();
+------------+
| database() |
+------------+
| saas       |
+------------+
1 row in set (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2024-04-24 11:36:28 |
+---------------------+
1 row in set (0.00 sec)

mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2024-04-24 11:38:30 |
+---------------------+
1 row in set (0.00 sec)

mysql> select curdate();
+------------+
| curdate()  |
+------------+
| 2024-04-24 |
+------------+
1 row in set (0.00 sec)

mysql> select curtiem();
ERROR 1305 (42000): FUNCTION saas.curtiem does not exist
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 11:39:30  |
+-----------+
1 row in set (0.00 sec)

mysql> select week();
ERROR 1064 (42000): 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 ')' at line 1
mysql> select week(now());
+-------------+
| week(now()) |
+-------------+
|          16 |
+-------------+
1 row in set (0.00 sec)

mysql> select year(now());
+-------------+
| year(now()) |
+-------------+
|        2024 |
+-------------+
1 row in set (0.00 sec)

mysql> select hour(now());
+-------------+
| hour(now()) |
+-------------+
|          11 |
+-------------+
1 row in set (0.00 sec)

mysql> select minute(now());
+---------------+
| minute(now()) |
+---------------+
|            42 |
+---------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), 5)
 -> ;
+---------------------+
| adddate(now(), 5)   |
+---------------------+
| 2024-04-29 11:42:47 |
+---------------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), 8);
+---------------------+
| adddate(now(), 8)   |
+---------------------+
| 2024-05-02 11:43:17 |
+---------------------+
1 row in set (0.00 sec)

mysql> select adddate(now(), -8);
+---------------------+
| adddate(now(), -8)  |
+---------------------+
| 2024-04-16 11:43:45 |
+---------------------+
1 row in set (0.00 sec)

mysql> select concat("hello", "world");
+--------------------------+
| concat("hello", "world") |
+--------------------------+
| helloworld               |
+--------------------------+
1 row in set (0.00 sec)

mysql> select concat("hello", "world", "saas");
+----------------------------------+
| concat("hello", "world", "saas") |
+----------------------------------+
| helloworldsaas                   |
+----------------------------------+
1 row in set (0.00 sec)

mysql> select concat("My", "SQL");
+---------------------+
| concat("My", "SQL") |
+---------------------+
| MySQL               |
+---------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 0, "MySQL");
+-----------------------------------------+
| insert("这是一个数据库", 3, 0, "MySQL") |
+-----------------------------------------+
| 这是MySQL一个数据库                     |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 2, "MySQL");
+-----------------------------------------+
| insert("这是一个数据库", 3, 2, "MySQL") |
+-----------------------------------------+
| 这是MySQL数据库                         |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 2, "关系");
+----------------------------------------+
| insert("这是一个数据库", 3, 2, "关系") |
+----------------------------------------+
| 这是关系数据库                         |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 3, 0, "关系");
+----------------------------------------+
| insert("这是一个数据库", 3, 0, "关系") |
+----------------------------------------+
| 这是关系一个数据库                     |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select insert("这是一个数据库", 5, 0, "关系");
+----------------------------------------+
| insert("这是一个数据库", 5, 0, "关系") |
+----------------------------------------+
| 这是一个关系数据库                     |
+----------------------------------------+
1 row in set (0.00 sec)

mysql> select lower("MySQL");
+----------------+
| lower("MySQL") |
+----------------+
| mysql          |
+----------------+
1 row in set (0.00 sec)

mysql> select upper("MySQL");
+----------------+
| upper("MySQL") |
+----------------+
| MYSQL          |
+----------------+
1 row in set (0.00 sec)

mysql> select substring("javaMySQLOracle", 5, 5)
 -> ;
+------------------------------------+
| substring("javaMySQLOracle", 5, 5) |
+------------------------------------+
| MySQL                              |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select count(*) from tb_stu;
+----------+
| count(*) |
+----------+
|        6 |
+----------+
1 row in set (0.00 sec)

mysql> select count(sid) from tb_stu;
+------------+
| count(sid) |
+------------+
|          6 |
+------------+
1 row in set (0.00 sec)

mysql> select count(1) from tb_stu;
+----------+
| count(1) |
+----------+
|        6 |
+----------+
1 row in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select max(score) from tb_stu;
+------------+
| max(score) |
+------------+
|         99 |
+------------+
1 row in set (0.00 sec)

mysql> select min(score) from tb_stu;
+------------+
| min(score) |
+------------+
|         59 |
+------------+
1 row in set (0.00 sec)

mysql> select sum(score) from tb_stu;
+------------+
| sum(score) |
+------------+
|        395 |
+------------+
1 row in set (0.00 sec)

mysql> select avg(score) from tb_stu;
+------------+
| avg(score) |
+------------+
|         79 |
+------------+
1 row in set (0.00 sec)

mysql> select * from tb_stu;
+------+--------------+------+------+-------+------+
| sid  | name         | sex  | tel  | score | age  |
+------+--------------+------+------+-------+------+
| 9527 | zhouxingxing | boy  | 119  |    99 |   20 |
| 9528 | qiuxiang     | girl | 110  |    80 |   18 |
| 9529 | shiliu       | girl | 114  |    59 |   30 |
| 9530 | qiuxiang     | girl | 110  |    80 |   18 |
| 9531 | zhuzhishan   | boy  | 112  |    77 |   22 |
| 9532 | chunxiang    | NULL | NULL |  NULL | NULL |
+------+--------------+------+------+-------+------+
6 rows in set (0.00 sec)

mysql> select max(score) from tb_stu;
+------------+
| max(score) |
+------------+
|         99 |
+------------+
1 row in set (0.00 sec)

mysql> select max(score) from tb_stu group by sex;
+------------+
| max(score) |
+------------+
|       NULL |
|         99 |
|         80 |
+------------+
3 rows in set (0.00 sec)

mysql> select min(score) from tb_stu group by sex;
+------------+
| min(score) |
+------------+
|       NULL |
|         77 |
|         59 |
+------------+
3 rows in set (0.00 sec)

任务:

创建一个学生表(student),包含以下字段,sid int,name varchar, sex char,score double,cid(班级编号) int

  1. 查询各个班级的 总人数

  2. 查询各个班级的平级分数

  3. 查询各个班级的成绩最高分

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/578290.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Kubernetes - CentOS7搭建k8s_v1.18集群高可用(kubeadm/二进制包部署方式)实测配置验证手册

Kubernetes - CentOS7搭建k8s集群高可用&#xff08;kubeadm/二进制包部署方式&#xff09;实测配置验证手册 前言概述&#xff1a; 一、Kubernetes—k8s是什么 Kubernetes 这个名字源于希腊语&#xff0c;意为“舵手“或”飞行员"。 Kubernetes&#xff0c;简称K8s&#…

无人机+巡飞弹:“柳叶刀”巡飞弹技术详解

“柳叶刀”巡飞弹技术是一种结合了无人机和巡飞弹的先进武器系统&#xff0c;由俄罗斯ZalaAero公司研制&#xff0c;首次公开亮相是在2019年的俄罗斯军队装备展上。该系统以其高度的灵活性和精确打击能力&#xff0c;在现代战场上扮演着重要角色。 系统组成&#xff1a;柳叶刀巡…

网络基础(day3)

【 理论重点】 网络是什么&#xff1f; &#xff08;网络是载体&#xff0c;目的是传输互联网中的数据&#xff0c;数据是终端产生<手机、电脑、服务器等>。&#xff09; 如何组件网络&#xff08;良性网络架构&#xff09;&#xff1f;有网络架构思维&#xff0c;得按层…

uniapp小程序订阅通知

服务 开通订阅服务 const tmplIds ref([tsdasdadasdfgdrtwexQHdEsjZV])//换成自己的 function confirm(){uni.requestSubscribeMessage({tmplIds: tmplIds.value,success: (res) > {// console.log(res)let auth_notice res[tmplIds.value[0]] accept ? 1 : 2 //1是接…

Alibaba Cloud Linux 3.2104 LTS 64位安装mysql 8.0报错

问题描述 Alibaba Cloud Linux 3.2104 LTS 64位安装mysql 8.0提示 Error&#xff1a; GPG check FAILED 问题原因 官方 MySQL 存储库的 GPG 密钥已过期&#xff0c;无法安装或更新 MySQL 包 mysql官网也提交了该bug&#xff1a; https://bugs.mysql.com/bug.php?id106188 …

matlab批量读取csv文件

matlab如何批量读取csv文件 在Matlab中&#xff0c;有多种方法可以批量读取CSV文件。下面是几种常用的实现方法&#xff1a; 方法一&#xff1a;使用dir函数获取文件列表 folder 文件夹路径; files dir(fullfile(folder, *.csv)); numFiles length(files);for i 1:numFi…

每日两题 / 78. 子集 17. 电话号码的字母组合(LeetCode热题100)

78. 子集 - 力扣&#xff08;LeetCode&#xff09; 通过二进制数的方式&#xff0c;若第k位为1&#xff0c;表示最终的集合中存在nums[k] 只要遍历所有可能的二进制数即可 class Solution { public:vector<vector<int>> subsets(vector<int>& nums) {…

BGP EVPN-Type2、3、5路由

文章目录 概述1、Type2 路由——MAC/IP 路由2、Type3 路由——Inclusive Multicast 路由3、Type5 路由——IP 前缀路由 概述 EVPN&#xff08;Ethernet Virtual Private Network&#xff09;是一种用于二层网络互联的 VPN 技术。 EVPN 技术采用类似于 BGP/MPLS IP VPN 的机制&…

【LeetCode:2095. 删除链表的中间节点 + 链表】

&#x1f680; 算法题 &#x1f680; &#x1f332; 算法刷题专栏 | 面试必备算法 | 面试高频算法 &#x1f340; &#x1f332; 越难的东西,越要努力坚持&#xff0c;因为它具有很高的价值&#xff0c;算法就是这样✨ &#x1f332; 作者简介&#xff1a;硕风和炜&#xff0c;…

安装crossover游戏提示容量不足怎么办 如何把游戏放到外置硬盘里 Mac电脑清理磁盘空间不足

CrossOver作为一款允许用户在非原生操作系统上运行游戏和应用程序的软件&#xff0c;为不同平台的用户提供了极大的便利。然而&#xff0c;随着游戏文件大小的不断增加&#xff0c;内置硬盘的容量往往无法满足安装需求。幸运的是&#xff0c;通过一些简单的步骤&#xff0c;我们…

表---商场 nine

CREATE TABLE gao25 (id int(11) NOT NULL AUTO_INCREMENT COMMENT 自增ID,shopId int(11) NOT NULL COMMENT 店铺ID,goodsId int(11) NOT NULL COMMENT 商品ID,attrId int(11) NOT NULL COMMENT 属性名称,attrVal text NOT NULL COMMENT 属性值,createTime datetime NOT NULL …

HTTP、模块化

HTTP协议 包括请求行、请求头、请求体 http常见请求方法&#xff1a; url统一资源请求符&#xff0c;其本身也是一个字符串 响应体的内容格式是非常灵活的,常见的响应体格式有: 1.HTML 2.CSS 3. JavaScript 4.图片 5.视频 6.JSON 响应状态码&#xff1a; IP本身是一个数字…

【每日算法】理论:深度学习基础 刷题:KMP算法思想

上期文章 【每日算法】理论&#xff1a;常见网络架构 刷题&#xff1a;力扣字符串回顾 文章目录 上期文章一、上期问题二、本期理论问题1、注意力机制2、BatchNorm 和 LayerNorm 的区别3、Bert 的参数量是怎么决定的。4、为什么现在的大语言模型都采用Decoder only架构&#x…

11 c++版本的贪吃蛇

前言 呵呵 这大概是 大学里面的 c 贪吃蛇了吧 有一些 面向对象的理解, 但是不多 最近 因为想要 在单片机上面移植一下 贪吃蛇, 所以 重新拿出了一下 这份代码 然后 将它更新为 c 版本, 还是 用了一些时间 这里 具体的实现 就不赘述, 仅仅是 发一下代码 以及 具体的使用…

NXP恩智浦 S32G电源管理芯片 VR5510 安全概念 Safety Concept (万字长文详解,配21张彩图)

NXP恩智浦 S32G电源管理芯片 VR5510 安全概念 Safety Concept (万字长文详解&#xff0c;配21张彩图) 1. 简介 本应用笔记描述了与S32G处理器和VR5510 PMIC相关的安全概念。该文档涵盖了S32G和VR5510的安全功能以及它们如何相互作用&#xff0c;以确保对ASIL D安全完整性级别…

Leetcode-轮转数字

189. 轮转数组 - 力扣&#xff08;LeetCode&#xff09;https://leetcode.cn/problems/rotate-array/ 目录 189. 轮转数组 - 力扣&#xff08;LeetCode&#xff09;https://leetcode.cn/problems/rotate-array/ 题目 解题 第一种方法 第二种方法 题目 给定一个整数数组 …

【深度学习(1)】研0和研1如何上手深度学习及定方向

深度学习&#xff08;1&#xff09; 基础部分书籍鱼书 (理论部分) 视频课程我是土堆&#xff08;代码部分&#xff09; 提升部分李沐的动手学深度学习李沐老师的书 定方向网站&#xff1a; paperwithcode谷歌学术找论文 基础部分 书籍 鱼书 (理论部分) 适合入门&#xff0c;…

Java项目:基于SSM框架实现的汽车推荐系统分前后台(源码+数据库)

一、项目简介 本项目是一套基于SSM框架实现的汽车推荐系统 包含&#xff1a;项目源码、数据库脚本等&#xff0c;该项目附带全部源码可作为毕设使用。 项目都经过严格调试&#xff0c;eclipse或者idea 确保可以运行&#xff01; 该系统功能完善、界面美观、操作简单、功能齐全…

Servlet和Tomcat运作过程

记录一下前后端请求交互过程&#xff08;不涉及Spring框架&#xff09;&#xff1a; 编写一个UserServlet 在web.xml文件中编写映射路径 编写前端

linux系统-FTP服务配置

目录 一、FTP简介 1.什么是FTP&#xff1f;&#xff1f;&#xff1f; 2.FTP的两种模式 二、安装配置FTP服务 1.关闭防火墙和核心防护 2.安装VSFTPD 3.修改配置文件 4.黑白名单设置 一、FTP简介 1.什么是FTP&#xff1f;&…
最新文章