Oracle中简单的查询

目录

1、简单查询

2、查询某个字段

3、条件查询

4、查询不重复的值

5、多条件查询

6、升序降序查询

7、为空或者不为空查询

8、模糊查询

9、包含查询

10、两个值之间的数据查询


--注释:table_name为表名     a为别名。

--直接查询某个表 用select * from语句

select * from table_name;

--查询某个字段 将* 替换成字段名

select a.id from table_name a; 

--查询一个表中的几个字段  之间用 ‘,’ 连接 

select a.id,a.code,a.address from table_name a;

--查询某个字段中唯一、不重复的值 用distinct进行查询

select distinct a.address from table_name a;

--依据条件查询 用where 筛选条件。例如:下文中的查询表中的code字段为’0331‘的相关信息

select * from table_name a where a.code='0331';

--多条件查询相关的信息  用and连接

select * from table_name a where a.code='0331816900' and a.is_valid=1;

--依据其中一个条件  用or连接

select * from table_name a where a.code='0331816900' or a.is_valid=1;

--依据表中的某个字段升序排序查询 用’order by‘ 在 ’order by‘后面接字段名

select * from table_name order by code;

--依据某个字段降序排序查询 用 'order by 字段名 desc'

select * from table_name order by code desc;

--查询某个字段不为空 在字段后面添加‘is not null’

select * from table_name a where a.is_valid is not null; 

--查询某个字段为空 在需要查询的字段后面添加'is null'

select * from table_name a where a.is_valid is null; 

--模糊查询 在字段后添加 'like' , '春%'查询‘春’字开头的信息   '%春%'查询包含所有的‘春’字的信息 

select * from table_name a where a.address like '%春%';

--依据某个字段的特定值查询 用 ‘in’ 包含特定查询的值

select * from table_name a where a.address in ('五龙家园二期38-1-501','泰兴镇泰兴里2-1-201');

--依据字段之间所有的值 查询某个值到某个值之间的所有信息用 ‘between 指定信息 and 指定信息’

select * from table_name a where a.code between 03318 and 05514;

这都是在Oracle中常见的查询,如有不对欢迎批评指正。

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值