当前位置:Gxlcms > 数据库问题 > 【转】软件测试工程师之必备SQL语句基础

【转】软件测试工程师之必备SQL语句基础

时间:2021-07-01 10:21:17 帮助过:3人阅读

username 1 张三 2 李四 3 王二 table2:
id job
1 teacher
2 student
4 worker
(1)内联查询(inner join……on……) select * from table1 a inner join table2 b on a.id=b.id 查询结果:
id username id job
1 张三 1 teacher
2 李四 2 student
(2)左外联(left outer join……on……) select * from table1 a left outer join table2 b on a.id=b.id 查询结果:
id username id job
1 张三 1 teacher
2 李四 2 student
3 王二 null null
(3)右外联(right outer join……on……) select * from table1 a right outer join table2 b on a.id=b.id
id username id job
1 张三 1 teacher
2 李四 2 student
null null 4 worker
(4)全外联(full outer join……on……) select * from table1 a full outer join table2 b on a.id=b.id
id username id job
1 张三 1 teacher
2 李四 2 student
3 王二 null null
null null 4 worker
6.group by分组 根据某一个或多个列表字段进行分组统计。 table1:
id name course score
1 张一 Chinese 80
2 张二 Chinese 60
3 张三 math 65
4 张三 Chinese 70
5 张一 math 90
  查询每个用户的最高成绩: select name,max(score) as max_score from table1 group by name 查询结果:先按用户名分组,再在每个组中查询找到最高分数
id name max_score
1 张一 90
2 张二 60
3 张三 70
  查询全班每科课程平均分 select course,avg(score) as avg_score from table1 group by course 查询结果:先按课程分组,再在每个组中查询找到平均分数
id course avg_score
1 chinese 70
2 math 77.5
  having的用法:同where用法,having与group by连用。where是筛选单个记录,having是筛选分组记录(先分组,后筛选)

作为一个初中级测试人员,一般情况下拥有以上的数据库知识就可以满足大部分的测试需要了。

【转】软件测试工程师之必备SQL语句基础

标签:软件测试   soft   into   多个   清空   group   删除表   http   UNC   

人气教程排行