subqueries

          1 Guidelines for Using Subqueries
          ?a Enclose subqueries in parenttheses
          ?b placce subqueries on the right side of the comparision condition
          ?c the order by clause in the subquery is not needed
          ?d using single-row operators with single-row subqueries and use multiple -row operator with multiple-row subqueries .
          ? single-row subqueries can work as a expression,and muitiple-row subqueries can only be used with in all any ,i will talk it later
          ? select last_name where job_idd=(select job_id
          ????????????????????????????????? from employees
          ????????????????????????????????? where imployee_id=141)
          2 The HAVING CLause with Subqueries
          ?a The Oracle server execute subqueries first
          ?b The Oracle return result into the HAVING clause of the main query
          ? select department_id,min(salary)
          ? from employee
          ? group by department_id
          ? having min(salary)>
          ???????????????????? (select min(salary)
          ????????????????????? from employees
          ????????????????????? where department_id=50);
          3 Multiple-Row Subqueries
          ? a Return? more than one row
          ? Using mutiple-row comparsion operator
          ? select employee_id
          ? from employees
          ? where salary<any
          ????????????????? (select salary
          ?????????????????? from employees
          ?????????????????? where job_id='ddd')

          ? select employee_id
          ? from employees
          ? where salary<all
          ????????????????? (select salary
          ?????????????????? from employees
          ?????????????????? where job_id='ddd')
          ?? select emp.last_name
          ?? from employees emp
          ?? where emp.employee_id not in
          ?????????????????????????????? (select mgr.manager_id
          ??????????????????????????????? from employees mgr)

          posted on 2006-09-22 16:25 康文 閱讀(260) 評(píng)論(0)  編輯  收藏 所屬分類: 數(shù)據(jù)庫(kù)

          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 应城市| 黄龙县| 城市| 永宁县| 前郭尔| 邯郸县| 盐池县| 镇安县| 云浮市| 左云县| 万山特区| 镇江市| 新疆| 福海县| 鹿邑县| 卓尼县| 株洲市| 商南县| 都安| 金昌市| 改则县| 玉田县| 河曲县| 通城县| 巴彦县| 乐清市| 兰西县| 阜宁县| 开鲁县| 拉孜县| 察隅县| 湘阴县| 涟水县| 五峰| 太湖县| 陇川县| 淳安县| 五华县| 城市| 岳西县| 广元市|