SQL2000数据库查询讲解004--查询满足条件的元组01:比较大小和确定范围

     查询满足条件的元组可以通过where子句实现。其常用的查询条件如下

         查询条件                       谓词

        比较                                =, >, <,  <=,  !=, <>,  !>,!<;    not  +  上述比较运算符

        确定范围                        between and ,   not  between  and ,   

        确定集合                        in ,    not in

        字符匹配                        like,  not like

        空值                                is null,      is not null

        多重条件                        and , or

(1)比较大小

例7:查询计算机系全体学生的名单

select sname 
from student
where sdept='cs'


例8:查询所有年龄在20岁以下的学生姓名及其年龄

select sname,sage
from student
where sage<20


可以这样写:

select sname,sage
from student
where not sage>=20

例9:查询考试成绩有不及格的学生的学号

select distinct sno
from sc
where Grade < 60

(2)确定范围

例10:查询年龄在20~23岁(包括20岁和23岁)之间的学生的姓名、系别和年龄

select sname, sdept,sage
from student
where sage between 20 and 23

例11:查询年龄不在20~23岁之间的学生的姓名、系别和年龄

select sname, sdept,sage
from student
where sage not between 20 and 23



 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值