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
)
---插入数据
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);
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,就需要使用两个"_",也就是"__"