select 语法+别名的使用+连接运算符+distinct+where+like+转义字符+between+in
来源:互联网 发布:java入门培训费用 编辑:程序博客网 时间:2024/06/06 00:26
select 语法
select 【distinct | all 】{* | 表达式 | 【列名,列名,… 】}
from {表名| 子查询 } 【别名】
【where condition】
【connect by condition 【start with condition】】
【group by expression【,….】
【havaing condition【,….】
【{union | intersect | minus }】
【order by expression asc|desc【,expression asc|desc….】】
【for update 【of 【schema】tableName|view】column】
【nowait】
all:查询的结果不管是重复值,都显示,默认是all
distinct:查询的结果有重复值,只显示一个
*:显示表和视图的全部列
connect by condition :查询是搜索的一个连接描述
start with condition:搜索的开始条件
group by expression:分组查询,后面可为列名或者表达式,表示对搜索的结果进行分组
order by expression :排序操作
for update 【of 【schema】tableName|view】column 】:在查询的时候对表进行锁定,不允许其他用户对表进行操作,直到解锁为止.
havaing condition:分组结果后的筛选条件
union | intersect | minus :分别实现集合的交集,并级,差级的操作
注意:havaing 针对的是group by
别名的使用
1.select age 年龄,name 名称 from
2.select age as 年龄,name as 名称 from
3.select * from student s
连接运算符||
将查询结果连接在一起
distinct
去掉查询中重复的值
显示不重复的数据,重复的数据就显示一个,在列前面使用。如果不指定distinct,默认all关键字。
distinct 后面跟很多列,这比较重复的值,是比较每一行相应的列是否都相同,如果都相同,就显示一行.
create table student2(
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
cno varchar2(2)
);
insert into student2 values(‘1’,’lili’,18,’1’);
insert into student2 values(‘2’,’lili’,18,’1’);
insert into student2 values(‘3’,’lili’,20,’1’);
insert into student2 values(‘4’,’lili’,21,’2’);
select distinct sname,sage,cno from student2
where
过滤查询结果
比较操作符
>,<,>=,<=,=,<>或!=
between and ,or
any,all
in,not in
like
is not null,is null
like
通配符 %,_
%:0个或者多个字符
_:一个字符
转义字符
可以使用escape关键字来定义转义字符]
列如:’%\%%’ escape ‘\’;
create table student2(
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
cno varchar2(2)
);
insert into student2 values(‘1’,’lilia’,18,’1’);
insert into student2 values(‘2’,’lilib’,18,’1’);
insert into student2 values(‘3’,’lilic’,20,’1’);
insert into student2 values(‘4’,’lilid’,21,’2’);
select sname,sage,cno from student2
where sname like ‘%lili%’
between
获取条件在一个区间所对应的数据
create table student2(
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
cno varchar2(2)
);
insert into student2 values(‘1’,’lili’,18,’1’);
insert into student2 values(‘2’,’lili’,18,’1’);
insert into student2 values(‘3’,’lili’,20,’1’);
insert into student2 values(‘4’,’lili’,21,’2’);
select sname,sage,cno from student2
where sage between 1 and 30
in
获取条件在一个集合所对应的数据
create table student2(
sno varchar2(10) primary key,
sname varchar2(20),
sage number(2),
cno varchar2(2)
);
insert into student2 values(‘1’,’lili’,18,’1’);
insert into student2 values(‘2’,’lili’,18,’1’);
insert into student2 values(‘3’,’lili’,20,’1’);
insert into student2 values(‘4’,’lili’,21,’2’);
select sname,sage,cno from student2
where sage in (18,20)
- select 语法+别名的使用+连接运算符+distinct+where+like+转义字符+between+in
- Oracle-18-select语句初步&SQL中用算术表达式&别名的使用&连接运算符%distinct&where子句
- oracle 基本语句练习(一) where, between ,null, like,转义字符,order by
- where查询条件的指定,between and,in,like
- oracle 连接运算符,连接字符串,||双竖线,在列别名上使用双引号,使用带有特殊字符的列别名
- Oracle学习4:distinct、between and、in、like详解
- SQL Where特殊的三个条件(between,in,like(字符串匹配,模糊查寻))
- WHERE语句中BETWEEN与IN的使用教程-MySQL
- day17 oracle ----查询(select) ---(BETWEEN ... AND... ,IN(list), LIKE , IS NULL , AND ,OR, NOT) ---(字符 , 数字 ,日期, 转换
- 字符转义运算符
- between与in的语法
- Oracle中使用escape关键字实现like匹配特殊字符,以及&字符的转义
- oracle之连接运算符和别名使用实例
- select查询 like模糊查询 as别名定义 逻辑运算符
- Difference between Select Unique and Select Distinct
- sql 中使用like时,关于转义符的问题
- 关于Like运算符的使用
- 转义字符的使用
- 两个多项式相乘和相加的java实现
- RaspberryPI LITE版本默认无SSH及显示屏下连接
- (扩展)欧几里得算法
- 拟牛顿法之L-BFGS算法
- 凸包问题详解(图解)(转载)
- select 语法+别名的使用+连接运算符+distinct+where+like+转义字符+between+in
- 插入排序:直接插入、折半插入排序源码及时间复杂度
- python_python2.7+python3.6安装与并存
- 【HTML】图像标签、文本、表格的颜色及其背景色
- 动态监听用户输入,延时提交内容
- BadVPN详解之--始记:透明socks代理与tun2socks
- 直方图均衡化和规定化
- javaweb开发中Servlet三大域对象的应用
- BadVPN详解之--编译与运行