当前位置:网站首页>MySQL第六次作业-查询数据-多条件

MySQL第六次作业-查询数据-多条件

2022-06-26 09:37:00 m0_61961898

  1. 查询教师表中T2到T9之间工资大于2000并且有岗位津贴的教师所有字段数据SELECT * FROM  lingjinzhengteacher where no between “T2” and “T9” and
  2. sal>2000 and comm is not null;

查询教师表中教师姓名不以字母“A”开头的教师所有字段数据,用工资排序,去前三条

select * from lingjinzhengteacher where name not like "a%"  order by sal limit 3

 

查询教师表中工资等于2000或者岗位津贴大于等于1000的教师所有字段数据

select * from lingjinzhengteacher where sal = 2000 or comm >=1000;

 

4.查询教师表中教师姓名以字母“d”开头并且含有”a”字母的教师号、教师姓名字段数据

select no, name from lingjinzhengteacher where name like "b%a%" ;

 5.查询教师表中教师姓名不以字符“e”开头的并且没有岗位津贴的教师号、教师姓名、工资、岗位津贴字段数据,用工资排序

select no, name,sal, comm  from lingjinzhengteacher where name not like "e%" and comm is null;

  6.查询课程表中带字母”L”的并且课时数大于等于50的课程名称、课时数字段数据

select name, class_hours from lingjinzheng_course where name like "%l%" and class_hours >=50;

 7.查询课程表中课程号在C5到C7之间或者没有课时数的所有字段数据

select * from lingjinzheng_course where no between "C5" and "C7" or class_hours is null;

 8.查询课程表中课时数不等于45并且课程名以“sh”结尾的课程名称、课时数字段数据

select name, class_hours from lingjinzheng_course where class_hours  !=  45 and name like "%sh" ;

 9.查询课程表中课程号不在C3、C5、C6中或者课时数等于45的所有字段数据,用课时数排序

select * from  lingjinzheng_course  where  no not in ("C3", "C5", "C6") or class_hours = 45 order by class_hours;

 查询授课表中序号在2到9之间或者周数为15的序号、教室号、周数字段数据

select id, class_num, week from lingjinzheng_schoolteaching
 where id between 2 and 9
 or week = 15;

 查询授课表中教师号在T2到T9之间并且教室在J栋的教师号、教室号字段数据, 用周数排序

select teacher_no, class_num from lingjinzheng_schoolteaching
    -> where teacher_no between "T2" and "T9"
    -> and class_num like "J%"
    -> order by week;

 

 查询授课表中周数不为空并且周数大于等于50的课程号、教室号、周数字段数据

 select course_no, class_num, week from lingjinzheng_schoolteaching
    -> where week is not null and week >= 50;

 

  1. 5 查询授课表中教室在一楼或者教室在三楼的所有字段数据, 用周数排序

 

select * from lingjinzheng_schoolteaching where class_num like "_1%" or class_num like "_3%" order by week;

 

原网站

版权声明
本文为[m0_61961898]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_61961898/article/details/124971455