数据库第六次作业:查询数据 多条件

一、查询教师表中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 name,prof from teacher where name like "d%" and prof like "%a%";

 


五、查询教师表中教师姓名不以字符“e”开头的并且没有岗位津贴的教师号、教师姓名、工资、岗位津贴字段数据,用工资排序
select name,sal,comm from teacher where name not like "e%" and comm=0 order by sal;


六、查询课程表中带字母”L”的并且课时数大于等于50的课程名称、课时数字段数据
select name,class_hours from shengdian_course where name like "%l%" and class_hours>=50;


七、查询课程表中课程号在C5到C7之间或者没有课时数的所有字段数据
select * from shengdian_course where no between "c5" and "c7" or class_hours="null";


八、查询课程表中课时数不等于45并且课程名以“sh”结尾的课程名称、课时数字段数据
select name,class_hours from shengdian_course where class_hours!=45 and name like "%sh";

 


九、查询课程表中课程号不在C3、C5、C6中或者课时数等于45的所有字段数据,用课时数排序
select * from shengdian_course where no not in ("c3","c5","c6") or class_hours=45 order by class_hours;


十、查询授课表中教室在Y栋2楼的所有课程号、教师号、教室号字段数据, 用周数排序,取前两条
select course_no,teacher_no,class_num from shengdian_school_teaching where class_num like "y2%" order by week limit 2;

 


十一、查询授课表中序号在2到9之间或者周数为15的序号、教室号、周数字段数据
select id,class_num,week from shengdian_school_teaching where id between 2 and 9 or week=15;


十二、查询授课表中教师号在T2到T9之间并且教室在J栋的教师号、教室号字段数据, 用周数排序
select teacher_no,class_num from shengdian_school_teaching where teacher_no between "t2" and "t9" and class_num like "j%" order by week;


十三、查询授课表中周数大于14或者课程号在C3、C5、C6中的所有字段数据
select * from shengdian_school_teaching where week>14 or course_no in ("c3","c5","c6");


十四、查询授课表中周数不为空并且周数大于等于15的课程号、教室号、周数字段数据
select course_no,class_num,week from shengdian_school_teaching where week is not null and week>=15;

 


十五、查询授课表中教室在一楼或者教室在三楼的所有字段数据, 用周数排序
select * from shengdian_school_teaching where class_num like "_1%" or class_num like "_3%" order by week;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值