oracle数据库查询篇SELECT STATEMENT


                     Select Statement                  
__________________________________________________________
#建表
create table lhj02(
    id number(4),
    name varchar2(10),
    age number(3),
    address varchar2(10),
    birthday date);
#插入数据
insert into lhj02 values(1,'lhj',22,'bj',sysdate);
insert into lhj02 values(2,'myp',18,'sjz',sysdate);
insert into lhj02 values(3,'zx',19,'sh',sysdate);
insert into lhj02 values(4,'khx',21,'cd',sysdate);
insert into lhj02 values(5,'scx',16,'hn',sysdate);
insert into lhj02 values(6,'xhj',20,'hb',sysdate);

insert into lhj02 values(7,'ltl',22,'sx',sysdate);

#更新数据

update lhj02 set age=18 where id=1;
update lhj02 set age=19 where id=2;
update lhj02 set id=9 where name='sd';

===================================================================
where
select * from lhj02 where age between 18 and 20;
select * from lhj02 where age>18 and age<=20;
select * from lhj02 where age in(18,20);
select * from lhj02 where age=18 or age=20;

==================================================================
like
select * from lhj02 where name like '%l%';
insert into lhj02 values(7,'ltl_d',22,'sx',sysdate);
insert into lhj02 values(7,'sd',22,'sx',sysdate);
select * from lhj02 where name like '_d';
select * from lhj02 where name like '%\_d%' escape '\';

==================================================================
null
insert into lhj02(id,name,age,birthday) values(8,'zhs',40,sysdate);
select * from lhj02 where address is null;
=================================================================
not
select * from lhj02 where age not between 19 and 21;
select * from lhj02 where age not in(19,22);
select * from lhj02 where address is not null;
=================================================================
多条件查询

SQL> select * from lhj02;

        ID NAME              AGE ADDRESS    BIRTHDAY
---------- ---------- ---------- ---------- ---------
         1 lhj                18 bj         22-SEP-08
         2 myp                19 sjz        22-SEP-08
         3 zx                 20 sh         22-SEP-08
         4 khx                18 cd         22-SEP-08
         5 scx                22 hn         22-SEP-08
         6 xhj                30 hb         22-SEP-08
         7 ltl                22 sx         22-SEP-08
         7 ltl_d              22 sx         22-SEP-08
         9 sd                 22 sx         22-SEP-08
         8 zhs                40            22-SEP-08

10 rows selected.

<1>select * from lhj02 where age>22 and address='bj' or address='sx';

        ID NAME              AGE ADDRESS    BIRTHDAY
---------- ---------- ---------- ---------- ---------
         7 ltl                22
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值