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 康文 閱讀(226) 評論(0)  編輯  收藏 所屬分類: 數據庫

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

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 铁力市| 彰化市| 万全县| 洛宁县| 砚山县| 上饶县| 襄汾县| 深圳市| 靖州| 石台县| 浦北县| 丰都县| 加查县| 家居| 鄯善县| 方正县| 农安县| 玉屏| 泸水县| 沙洋县| 广昌县| 肥乡县| 汉阴县| 五峰| 精河县| 阳东县| 青岛市| 海淀区| 甘泉县| 汝南县| 集贤县| 会东县| 垣曲县| 田林县| 苗栗县| 吴江市| 濮阳县| 弥渡县| 板桥市| 五大连池市| 什邡市|