oracle学习笔记(五) SQL操作符

SQL操作符

算术操作符:+加,-减,*乘,/除

比较操作符:

  • <,>,=,!=,<>,<=,>=
    常用的判断,<>和!=相同
  • between \(lower_val\) and \(hight_val\)
    between .. and.. 包括两端
--查询20<=age<=21的学生数据
select * from student where age between 20 and 21
  • not between \(lower_val\) and \(hight_val\)
    与上面相反
  • in(值列表), not in(值列表)
--查询年龄是20或21的学生数据
select * from student where age in (20,21)
  • is null, IS NOT NULL
    是否为空
  • like, not like
    匹配 ( 通配 )操作符:
    • % 匹配任意多个字符;
    • _ 匹配任意单个字符;
    • 可以使用escape '$'指定转义字符,默认是""
--姓氏为张的学生,张二,张三,张四五都符合条件
select * from student where name like '张%';
--名字含有三的
select * from student where name like '%三%';
--姓氏为张,名字只有两个字的学生
select * from student where name like '张_';
--名字中包含%号的
select * from student where name like '%\%%' escape '\' ;

逻辑操作符: AND, OR, NOT

与,或

连接操作符: ||

-- 查询student表中你的num和name列,并把这两列显示出来
select num||,||name from student

集合(查询的结果集)操作符

下一章《高级查询》再讲
a)UNION 联合,将两个查询结果拼起来
b)UNION ALL 联合所有,多出现重复行
c)INTERSECT 交集
d)MINUS 减集

posted @ 2019-04-22 16:57  Stars-one  阅读(636)  评论(0编辑  收藏  举报