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

mac2022-06-30  94

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 减集

转载于:https://www.cnblogs.com/chaoyang123/p/11549346.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)