Oracle项目实践之---模糊查询表中的数据(本人实例亲测)

1:案例演示:

1:创建表

CREATE TABLE db_fruits

(

f_id varchar2(10) not null,

s_id number(6) not null,

f_name varchar(25) not null,

f_price number(8,2) not null

 

)

2:插入数据

---插入数据

insert into db_fruits values ('a1',101,'apple',5.2);

insert into db_fruits values ('b1',102,'blueberry',10.2);

insert into db_fruits values ('c1',103,'melon',4.3);

insert into db_fruits values ('bs1',104,'orange',11.2);

insert into db_fruits values ('bs2',105,'grape',7.2);

insert into db_fruits values ('bs3',106,'melon',5.3);

insert into db_fruits values ('bs4',107,'coconut',9.2);

insert into db_fruits values('bs5',108,'cherry',7.2);

insert into db_fruits values('bs6',109,'lemoon',10.3);

insert into db_fruits values('bs7',110,'blueberry',9.2);

insert into db_fruits values('bs8',111,'berry',7.2);

insert into db_fruits values('bs9',112,'chrry',10.3);

insert into db_fruits values('bs10',113,'chbby',23.3);

 

3:模糊查询

1:通配符%

1:模糊查询以B开头的水果名称,不管后面的字母是什么

select * from db_fruits f where f.f_name like 'b%'

 

2:查询f_name中包含b的记录,只要水果名字带b的都进行显示

select * from db_fruits f where f.f_name like '%b%'

 

3:查询水果中以c开头,并且以y结尾的水果名称

 

2:通配符_

 

下划线通配符“_”,一次只能匹配任意一个字符,如果要匹配多个字符,需要使用相同个数的"_",列如,你想匹配水果名称字符第2个开通的是e,就需要使用两个"_",也就是"__"

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值