Chinaunix首页 | 论坛 | 博客
  • 博客访问: 372991
  • 博文数量: 57
  • 博客积分: 4020
  • 博客等级: 上校
  • 技术积分: 647
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-17 15:57
文章分类

全部博文(57)

文章存档

2009年(22)

2008年(35)

我的朋友

分类: Oracle

2009-05-15 17:14:21

select语句中使用where
eg:
= 的使用
SQL> select * from test1 where name='田月星';
 
        ID NAME
---------- --------------------
         3 田月星
         5 田月星

> 的使用
SQL> select * from test1 where id>3;
 
        ID NAME
---------- --------------------
         4 田月超
         5 田月星
         6 yuechaotian

between 小值 and 大值 的使用
SQL> select * from test1 where id between 2 and 5;
 
        ID NAME
---------- --------------------
         2 xingxing
         3 田月星
         4 田月超
         5 田月星
         2 李连杰

in()的使用
SQL> select * from test1 where id in(1,3,5,6);
 
        ID NAME
---------- --------------------
         1 张学友
         3 田月星
         5 田月星
         6 yuechaotian
 
like模糊查询
% 代表至多个任意字符
_ 代表一个任意字符
eg:
SQL> select * from test1 where name like '%星';
 
        ID NAME
---------- --------------------
         3 田月星
         5 田月星
SQL> select * from test1 where name like '_月星';
 
        ID NAME
---------- --------------------
         3 田月星
         5 田月星

测试一个值是否为空
我先添加一条name为空的记录
eg:
SQL> insert into test1 values(8,null);
 
已创建 1 行。
 
SQL> select * from test1;
 
        ID NAME
---------- --------------------
         1 张学友
         2 xingxing
         3 田月星
         4 田月超
         5 田月星
         6 yuechaotian
         8
         2 李连杰
 
已选择8行。
然后测试
SQL> select * from test1 where name is null;
 
        ID NAME
---------- --------------------
         8

SQL语句在SQLplus中的交互使用图解:

阅读(1672) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~