-----------------产生笛卡儿积------------------------------------
select * from emp,dept; --不带条件时,记录数为14*4 =56条记录
select * from emp cross join dept;--交叉连接,同上

select count(*)from emp;

---左连接( 返回包括左表中的所有记录和右表中联结字段相等的记录 )
select d.dname,e.ename from emp e,dept d where e.deptno=d.deptno(+);
select d.dname,e.ename from emp e left join dept d on e.deptno=d.deptno;
select * from emp e left outer join dept d on e.deptno=d.deptno;

--右连接(返回包括右表中的所有记录和左表中联结字段相等的记录) 
select d.dname,e.ename from emp e,dept d where e.deptno(+)=d.deptno;
select d.dname,e.ename from emp e right join dept d on e.deptno=d.deptno;
select * from emp e right outer join dept d on e.deptno=d.deptno;

---默认/内连接(只返回两个表中联结字段相等的行)
select d.dname,e.ename from emp e,dept d where e.deptno=d.deptno;
select * from emp e inner join dept d on e.deptno=d.deptno;--内连接

select * from emp e inner join dept d using(deptno);---使用using替换表达式

--自连接(自动对两个表按照同名的列进行内连接)
select * from emp natural join dept;

---全外连接(合并左右连接)
select * from emp full outer join dept using(deptno);

---合并结果集:UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型

select empno from emp UNION select deptno from dept;

select empno,ename from emp UNION ALL select deptno,dname from dept;

Union:对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序;
Union All:对两个结果集进行并集操作,包括重复行,不进行排序;

oracle学习篇四:多表查询的更多相关文章

  1. Oracle学习笔记_04_多表查询

    一.概念: 1.多表连接有以下几种分法: (1)内连接           vs          外连接 (左.右.满) (2)等值连接        vs         不等值连接 (3)非自连 ...

  2. Oracle学习(五):多表查询

    1.知识点:能够对比以下的录屏进行阅读 SQL> --等值连接 SQL> --查询员工信息: 员工号 姓名 月薪 部门名称 SQL> select empno,ename,sal,d ...

  3. oracle学习篇六:子查询

    -- 1.查询比7654工资要高的员工 select * from emp where sal>(select sal from emp where empno=7654); ---2.查询最低 ...

  4. oracle学习篇三:SQL查询

    select * from emp; --1.找出部门30的员工select * from emp where deptno = 30; --2.列出所有办事员(CLERK)的姓名,变化和部门编号se ...

  5. oracle学习 第一章 简单的查询语句 ——03

    1.1最简单的查询语句 例 1-1 SQL> select * from emp; 例 1-1 结果 这里的 * 号表示全部的列.它与在select 之后列出全部的列名是一样的.查询语句以分号( ...

  6. Oracle中把一张表查询结果插入到另一张表中

      1. 新增一个表,通过另一个表的结构和数据 create table XTHAME.tab1 as select * from DSKNOW.COMBDVERSION 2. 如果表存在: inse ...

  7. oracle 基础SQL语句 多表查询 子查询 分页查询 合并查询 分组查询 group by having order by

    select语句学习 . 创建表 create table user(user varchar2(20), id int); . 查看执行某条命令花费的时间 set timing on: . 查看表的 ...

  8. Oracle组函数、多表查询、集合运算、数据库对象(序列、视图、约束、索引、同义词)等

    count组函数:(过滤掉空的字段) select count(address),count(*) from b_user max() avg() min(),sum() select sum(age ...

  9. oracle系列笔记(2)---多表查询

    多表查询     这篇文章主要讲四点: (1)oracle多表查询    (2)SQL99标准的连接查询   (3)子查询     (4)分级查询 oracle多表查询有两种方式,一种是oracle所 ...

随机推荐

  1. Python之路系列:面向对象初级:静态属性、静态方法、类方法

    一.静态属性 静态属性相当于数据属性. 用@property语法糖装饰器将类的函数属性变成可以不用加括号直接的类似数据属性. 可以封装逻辑,让用户感觉是在调用一个普通的数据属性. 例子: class ...

  2. js去重方法

    function remove(array){ var obj={}; newarray=[]; for(var i in array){ console.log(i); var arg=array[ ...

  3. Unity---高度解耦和

    介绍 先举一个简单的例子: 在UGUI中新建一个Button和Text,要求实现点击Button改变Text中的文字. 我的第一反应就是在Button上添加一个脚本,获取点击事件来改变Text的内容. ...

  4. 题解 P1632 点的移动

    P1632 点的移动 题目描述 平面上有N个整数坐标点.如果将点(x0,y0)移动到(x1,y1),则需要的代价为|x0-x1|+|y0-y1|.求使得K(K=1,-,N)个点在同一位置上最少需要的代 ...

  5. 条目十二《切勿对slt容器的线性安全性又不切实际的依赖》

    条目十二<切勿对slt容器的线性安全性又不切实际的依赖> 这一条目,我想用简短而有力的语句来总结. stl库是为了照顾大多数情况,而不是某一领域,如果在库层次实现线性安全,很大可能是对性能 ...

  6. UVA - 11995 模拟

    #include<iostream> #include<cstdio> #include<algorithm> #include<cstdlib> #i ...

  7. js 获取滚动条事件

    function getScroll() { return { left: window.pageXOffset || document.documentElement.scrollLeft || d ...

  8. paraview添加vector

    https://youtu.be/cygVdhn-kG0 (须自行FQ)

  9. Magic Odd Square (思维+构造)

    Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both ma ...

  10. BZOJ 5421: 收藏家

    传送门 直接搞很复杂,考虑转化问题 题目只要求第1个人最多能获得的物品数量 所以如果一种物品拥有多个和一个是没区别的 那么考虑每种物品对第1个人怎样贡献 显然要经过一些交换最终到达第一个人那里 发现很 ...