-----------------产生笛卡儿积------------------------------------
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. 题解 P3252 【[JLOI2012]树】

    \(\Huge{[JLOI2012]树}\) 题目描述 在这个问题中,给定一个值S和一棵树.在树的每个节点有一个正整数,问有多少条路径的节点总和达到S.路径中节点的深度必须是升序的.假设节点1是根节点 ...

  2. (Keil) Debug & Simulation 操作

    0x00 printf在MCU環境下print debug error message,利用Logic Analyzer模擬MCU register or GPIO狀態. 若是要要使用printf函數 ...

  3. angularJs表格效果

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  4. office 2013 破解工具 及 软件下载

     win7/win8/win10  office2013 破解工具 下载地址: https://pan.baidu.com/s/1sZeJOCWq1fZ3KIOWvmrAQQ office2013  ...

  5. fiddler抓安卓

    1.tools connections  左 allow remote computersconnect  选中 2.配置模拟器 wifi 长按 修改网络 ip电脑ip 端口8888 ps:修改完不要 ...

  6. PHP 实时生成并下载超大数据量的 Excel 文件

    //另外由于excel数据是从数据库里逐步读出然后写入输出流的所以需要将PHP的执行时间设长一点 //(默认30秒)set_time_limit(0)不对PHP执行时间做限制. set_time_li ...

  7. C++_类入门3-嵌套类

    可以将类B声明在另一个类中.在另一个类A中声明的类B被称为嵌套类(nested class). 类A的成员函数可以创建和使用嵌套类B的对象. 当且仅当声明为公有部分时,才能在类A的外面使用嵌套类.而且 ...

  8. Angular 组件 mat-paginator 自定义详细用法

    Demo: https://stackblitz.com/edit/angular-5mgfxh?file=main.ts 官方文档: https://material.angular.io/comp ...

  9. kerl build error

    删除 archives文件夹就行了

  10. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...