Home > Database > Mysql Tutorial > Oracle集合查询

Oracle集合查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:12:35
Original
1041 people have browsed it

Oracle集合查询,Order by 字句只能出现在最后一个语句上,第一个select语句接受的列 名称或者别名

Linux公社

首页 → 数据库技术

背景:

阅读新闻

Oracle集合查询

[日期:2012-03-14] 来源:Linux社区  作者:java958199586 [字体:]

并集

Select  * from emp where deptno=10 union select * from emp where deptno=20;

Select  * from emp where deptno=10 union all select * from emp where deptno=20;

Select * from emp where ename like ‘%A%’ or ename like ‘%M%’;

Select * from emp where ename like ‘%A%’ union ename like ‘%M%’;//去掉共有部分

Select * from emp where ename like ‘%A%’ union all ename like ‘%M%’;//不去掉

交集

Select * from emp where ename like ‘%A%’ intersect  ename like ‘%M%’;//共有的部分

差集

属于第一不属于第二

Order  by 字句只能出现在最后一个语句上,第一个select语句接受的列 名称或者别名

查询结果的列名 必须与第一个select的列名一致

Select * from (select * from emp where sal between 700 and 1300 union select * from emp where sal between 1200 and 1400) order by sal desc;

select  ename,sal from emp where sal between 700 adn 1300 union select ename,sal from emp where sal between 1200 and 1400 order by sal deces;

select语句中参数类型和个数要一致

可以使用括号改变集合执行的顺序

集合运算采用第一个语句的表头作为表头

linux

  • 0
  • Oracle索引扫描

    Oracle 事务处理详解

    相关资讯       oracle数据库教程 

    图片资讯      

    本文评论   查看全部评论 (0)

    评论声明

    最新资讯

    本周热门

    Linux公社简介 - 广告服务 - 网站地图 - 帮助信息 - 联系我们
    本站(LinuxIDC)所刊载文章不代表同意其说法或描述,仅为提供更多信息,,也不构成任何建议。


    Copyright © 2006-2011 Linux公社 All rights reserved 浙ICP备06018118号

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template