Using SET Operators.

          1 The Union Operator
          ?The union operator returns results form both queries after eliminating duplications.\
          ?select employee_id,job_id
          ?from employees
          ?uniion
          ?select employ_id ,job_id
          ?from job_history;
          2 the all operator
          ?The union all opertor reutrn result from both queries,including all duplications
          3 interset
          ?select ster_id,qty from sales where qty>20;
          ?intersect
          ?select ster_id,qty from sales where ster_id like '7%';
          4 minus
          ?select ster_id,qty from sales where qty>20
          ?minus
          ?select ster_id from sales where ster_id like '7%'

          5 set operator guidelines
          ?. teh expressions in the select list must match in number and data type;
          ?. Parentheses can be used to alter the sequence of the execution
          ?.The order by clause:
          ??? can appear only at the very end of the statement
          ??? will accept the column name,aliases from thee firest select statement ,or thee positional notation
          ?.Duplicate row are atuomatically eliminated except in union all.
          ?.Column names from the first query appear in the result
          ?.The output is sorted in ascending order by default except in union all
          6 matching the select statement
          ?select department_id,to_number(null),location,hire_date
          ?from employees
          ?union
          ?select department_id,location_id,to_date(null)
          ?from departments;

          ?select employee_id,job_id,salary
          ?from employees
          ?union
          ?select employee_id,job_id,0
          ?from job_history;
          7 Controlling the order of the rows
          ?select 'sing' as "my dream" ,3,a_dummy
          ?from dual
          ?union
          ?select 'like''d like to teach',1
          ?from dual
          ?union
          ?select 'the world to',2
          ?from dual
          ?order by 2;

          posted on 2006-10-11 14:51 康文 閱讀(225) 評論(0)  編輯  收藏 所屬分類: 數據庫

          <2006年10月>
          24252627282930
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 七台河市| 新丰县| 皋兰县| 海宁市| 新和县| 广德县| 许昌县| 长岭县| 菏泽市| 昭平县| 莲花县| 津南区| 江北区| 邵阳市| 农安县| 揭西县| 宜兴市| 论坛| 霍城县| 鄄城县| 黔西县| 西城区| 建湖县| 镇远县| 黔东| 通化市| 铜山县| 厦门市| 黑龙江省| 宣恩县| 紫阳县| 武威市| 静宁县| 惠水县| 新龙县| 溧阳市| 二手房| 东莞市| 南城县| 绥中县| 葵青区|