码迷,mamicode.com
首页 > 其他好文 > 详细

运算符

时间:2017-10-04 14:10:56      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:order   匹配   ott   sel   between   sele   like   开头   red   

       s
           select * from scott.emp where deptno=10;           /显示scott.emp表中部门是10的人员信息;
           select * from scott.emp where deptno=‘10’;       /显示scott.emp表中部门是10的人员信息;
           select * from scott.emp where ename=‘ALLEN’;      /显示scitt.emp表中名字是ALLEN的列出信息;
           select 5+4*7 “结果” from dual;                             /计算5+4*7的结果,dual相当于空表。也可以理解为回收站。
           select sysdata from dual;                                   /显示日期。格式:号-月-年
           select * from scott.emp where hiredate > ‘01-JAN-87‘; /查看scott.tmp表中大于一号一月1987年的入职日期;

           select * from scott.emp where sal <= 1000;         /查看scott.emp表中工资小于等于1000的工资。
           select * from scott.emp where sal >=2500 and sal <= 3500;    /查看scott.emp表中公司大于2500并小于3500工资的列出。
        select * from scott.emp where sal between 2500 and 3500;    /查看scott.emp表中公司大于2500并小于3500工资的列出。
        select * from scott.emp where sal = 800 or sal = 950;        /查看工资等于绝对金额,其他的则不显示。
        select * from scott.emp where sal in (800,950);                /查看工资等于绝对金额,其他的则不显示。
        select * from scott.emp where sal != 800 and sal != 950;    /显示金额不等于800和950的。则其他的显示。
    select * from scott.emp where job<>‘CLERK’ and sal<3000; /查询scott.emp表,不查找CLERK的信息,并且公司不小于3000;
        select * from scott.emp where sal not in (800,950);            /显示金额不等于800和950的。则其他的显示。
        select * from scott.emp where ename = ‘ALLEN‘;                /显示scott.emp表中ALLEN用户的全部信息。
    like 可以实现数据的模糊查询操作,如果想使用like则不行使用如下两个符号:
      _:匹配任意的一位符号;
      %;匹配任意的符号(包含匹配0位、1位、多位)
        select * from scott.emp where ename = ‘ALLEN‘;                    /查找ALLEN的信息
        select * from scott.emp where ename like ‘_A%‘;                    /_表示站一位字符,A表示带A字母的、%表示其他。
    select * from scott.emp where ename not  like ‘A%‘;     /A表示带A字母开头的英文名称不会显示。
    select * from scott.emp where deptno like ‘10’;      /查询scott.emp表中查询编号10
        select * from scott.emp where comm is not null;                /查看scott.emp表中COMM选项中不是空值的显示出来。

        select * from scott.emp order by sal asc;                     /查看scott.emp表中的工资,顺序是升序,从少到多。
        select * from scott.emp order by sal desc;                     /查看scott.emp表中的工资,顺序是降序,从多到少。
        select * from scott.emp order by deptno asc, sal desc;        /查看scitt.emp表中部门为升序,工资为降序。
        select * from scott.emp order by 8 asc, 6 desc;            /查看scitt.emp表中部门为升序,工资为降序。这种方式用的很少。
    select count(*) from scott.emp                       /统计表中有多少行

运算符

标签:order   匹配   ott   sel   between   sele   like   开头   red   

原文地址:http://www.cnblogs.com/Juvenile/p/7625310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!