数据库中select语言

–显示全部学生的姓名、班级名和所在院系
select sname 姓名,LEFT(sno,8) 班级名, department 所在院系 from tb_student
–列出学生的政治面貌重复的记录自动去掉
select distinct polity from tb_student
–返回课程表中的前20%的记录
select top 20 percent *from tb_course
–显示课程表中课程号、课程名、先修课(用列别名的三方式显示)
select c_no 课程号,课程名=cname,rcno as 先修课 from tb_course
–列出计算机2班女同学的名单
select *from tb_student where sex='女’and department=‘计算机’and sno like ‘%02%’
–列出年龄不在18岁到20岁之间的所有学生名单
select *from tb_student where year(getdate())-year(birthday) not between 18 and 20
–列出既不是电子系,也不是国际贸易的学生的学号、姓名、和所在院系
select sno,sname,department from tb_student where department not in(‘电子系’,‘国际贸易’)
–列出’苏?步‘的老师名
select *from tb_teacher where sn like ‘苏_步’
–显示学生表中19岁以上女同学的信息
select *from tb_student where year(getdate())-year(birthday)>19 and sex=‘女’
–查询1998年以后出生的学生信息
select *from tb_student where YEAR(birthday)>1998
–在成绩表中查询成绩从70-90分的学生的信息
select *from tb_score where grade between 70 and 90
–查询学生表中姓张和姓王的同学
select *from tb_student where left(sname,1) in(‘张’,‘王’)
–学生表中找到所有姓李名lan(蓝/兰/阑)的同学
select *from tb_student where sname like’李名[蓝兰阑]’
–学生表中找到所有不姓张的同学
select *from tb_student where LEFT(sname,1) not in(‘张’)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值