-----------------产生笛卡儿积------------------------------------
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. delphi 给字符指针分配内存

    今天,对接第三方dll的时候出现如下问题: 接口声明如下: long BL_tradeBalance (char *MerchantNumber,char *PosId,char *OperatorN ...

  2. Ajaxa的原生使用方法

    Ajax整合了JavaScript.xml.CSS等现有技术而成,全称为Asynchronous JavaScript And XML,即异步的 JavaScript和xml.它使用了JavaScri ...

  3. 4.jQuery和DOM 对象之间的相互转换

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. 一、pytest的介绍和安装

    需要针对一个项目系统开发一套UI自动化测试脚本,自己结合着学习,采用了pytest去实现,这里留下记录. 什么是pytest pytest 是一个非常成熟的全功能的Python测试框架 可以胜任uni ...

  5. centos配置免密登录

    一.准备工作 1.先准备两台centos机器.例如:192.168.1.100和192.168.1.101两台机器,配置101免密登录100 2.默认centos会自带ssh和stfp,机器未安装,请 ...

  6. POJ1358 Agri-Net

    题目链接 就是裸的最小生成树,复习一下. prim算法: G=(V,E),V是点集,E是边集 假设T=(U,TE)是最小生成树.U,TE初始化为空 首先从V中任取一点 假设取V1,然后U={V1},只 ...

  7. HDU_1846 Brave Game 【巴什博弈】

    题目: 十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫<勇敢者的游戏>(英文名称:Zathura),一直到现在,我依然对于电影中的部分电脑特技印象深刻. 今天, ...

  8. Largest Submatrix of All 1’s(思维+单调栈)

    Given a m-by-n (0,1)-matrix, of all its submatrices of all 1's which is the largest? By largest we m ...

  9. vue 中引用 百度地图

    1.在 http://lbsyun.baidu.com/ 申请 秘钥 2.在index.html文件中引入 <script src="http://api.map.baidu.com/ ...

  10. POJ - 1222 / POJ - 3279 枚举第一行

    说好的高斯消元法呢,暴搜都能0ms 这种翻转就是枚举第一行控制变量下面行就全都确定了 代码参考挑战程序设计例题 #include<iostream> #include<algorit ...