查询教师表中T2到T9之间工资大于2000并且有岗位津贴的教师所有字段数据
select * from teacher where no between "T2" and "T9" and sal >2000 and comm is not null;

查询教师表中教师姓名不以字母“A”开头的教师所有字段数据,用工资排序,去前三条
select * from teacher where name not like "a%" order by sal limit 3,7;

查询教师表中工资等于2000或者岗位津贴大于等于1000的教师所有字段数据
select * from teacher where sal = 2000 or comm >= 1000;
查询教师表中教师姓名以字母“d”开头并且含有”a”字母的教师号、教师姓名字段数据
select * from teacher where name like "d%a%"
查询教师表中教师姓名不以字符“e”开头的并且没有岗位津贴的教师号、教师姓名、工资、岗位津贴字段数据,用工资排序
select * from teacher where name not like "e%" and comm is not null order by sal;

查询课程表中带字母”L”的并且课时数大于等于50的课程名称、课时数字段数据
select * from course where name like "%L%" and class_hours >= 50;
查询课程表中课程号在C5到C7之间或者没有课时数的所有字段数据
select * from course where no between "c5" and "c7" or class_hours = 0;
查询课程表中课时数不等于45并且课程名以“sh”结尾的课程名称、课时数字段数据
select * from course where class_hours != 45 and name like "%sh";
查询课程表中课程号不在C3、C5、C6中或者课时数等于45的所有字段数据,用课时数排序
select * from course where no not in ("c3","c5","c6") or class_hours = 45 order by class_hours;

查询授课表中教室在Y栋2楼的所有课程号、教师号、教室号字段数据, 用周数排序,取前两条
select * from school_teaching where class_num like "y2%" order by week limit 2;
查询授课表中序号在2到9之间或者周数为15的序号、教室号、周数字段数据
select * from school_teaching where id between "2" and "9" or week = 15 ;

查询授课表中教师号在T2到T9之间并且教室在J栋的教师号、教室号字段数据, 用周数排序
select * from school_teaching where id between "2" and "9" or week = 15 ;
查询授课表中周数大于14或者课程号在C3、C5、C6中的所有字段数据
select * from school_teaching where week > 14 or course_no in ("c3","c5","c6");

查询授课表中周数不为空并且周数大于等于15的课程号、教室号、周数字段数据
select * from school_teaching where week != 0 and week > 15;
查询授课表中教室在一楼或者教室在三楼的所有字段数据, 用周数排序
select * from school_teaching where class_num like "_1%" or class_num like "_3%" order by week;

本文介绍了多个SQL查询实例,包括教师工资与岗位津贴查询、教师姓名条件筛选、课程信息匹配等,涵盖了数据过滤、排序、组合条件判断等多种操作,展示了SQL在数据检索中的灵活性和实用性。








1500

被折叠的 条评论
为什么被折叠?



