oracle学习篇四:多表查询
-----------------产生笛卡儿积------------------------------------
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学习篇四:多表查询的更多相关文章
- Oracle学习笔记_04_多表查询
一.概念: 1.多表连接有以下几种分法: (1)内连接 vs 外连接 (左.右.满) (2)等值连接 vs 不等值连接 (3)非自连 ...
- Oracle学习(五):多表查询
1.知识点:能够对比以下的录屏进行阅读 SQL> --等值连接 SQL> --查询员工信息: 员工号 姓名 月薪 部门名称 SQL> select empno,ename,sal,d ...
- oracle学习篇六:子查询
-- 1.查询比7654工资要高的员工 select * from emp where sal>(select sal from emp where empno=7654); ---2.查询最低 ...
- oracle学习篇三:SQL查询
select * from emp; --1.找出部门30的员工select * from emp where deptno = 30; --2.列出所有办事员(CLERK)的姓名,变化和部门编号se ...
- oracle学习 第一章 简单的查询语句 ——03
1.1最简单的查询语句 例 1-1 SQL> select * from emp; 例 1-1 结果 这里的 * 号表示全部的列.它与在select 之后列出全部的列名是一样的.查询语句以分号( ...
- Oracle中把一张表查询结果插入到另一张表中
1. 新增一个表,通过另一个表的结构和数据 create table XTHAME.tab1 as select * from DSKNOW.COMBDVERSION 2. 如果表存在: inse ...
- oracle 基础SQL语句 多表查询 子查询 分页查询 合并查询 分组查询 group by having order by
select语句学习 . 创建表 create table user(user varchar2(20), id int); . 查看执行某条命令花费的时间 set timing on: . 查看表的 ...
- Oracle组函数、多表查询、集合运算、数据库对象(序列、视图、约束、索引、同义词)等
count组函数:(过滤掉空的字段) select count(address),count(*) from b_user max() avg() min(),sum() select sum(age ...
- oracle系列笔记(2)---多表查询
多表查询 这篇文章主要讲四点: (1)oracle多表查询 (2)SQL99标准的连接查询 (3)子查询 (4)分级查询 oracle多表查询有两种方式,一种是oracle所 ...
随机推荐
- 【guava】前提条件
guava为编写漂亮代码提供了很大的便利,今天,我想向你展示下我是怎么使用预判断来避免不必要的if/throw 申明,使用选择来提升代码逻辑性. 预判断并不是新东西,Apache Commons项目有 ...
- linux负载均衡与性能监控
平均负载是单位时间内, 系统处于可运行状态和不可中断状态的平均进程数( 平均活跃进程数 ) 可运行状体好理解, 就是进程正在运行状态Running和可运行状态Runnable... 这里需要注意的是 ...
- 一款很好用的页面滚动元素动画插件-AOS.JS
aos.js是一款效果超赞的页面滚动元素动画jQuery动画库插件.该动画库可以在页面滚动时提供28种不同的元素动画效果,以及多种easing效果.在页面往回滚动时,元素会恢复到原来的状态. 加载方法 ...
- 记录一些好用的iOS第三方库
CBStoreHouseRefreshControl:一个效果很酷炫的下拉刷新控件. ZLSwipeableView:ZLSwipeableView是一个方便做出卡片效果的UI库,支持各种卡片的滑动效 ...
- HDU - 5997 树状数组+set
和之前一道省选题目很像: (梦幻布丁): 我们维护的时候用树状数组维护,在断电处打上标记: 合并的时候小的合并到大的里面: #include<iostream> #include<c ...
- Optimizing and caching browser bundles...
扎心了,老铁!!! 他妈的,弄了几天都是卡在这里!!上网查了一下.说是我的内存不够,好吧.我慢慢等,然而让我等了好几天都没什么反应..两天了,一直卡在这里.今天在虚拟机也是发狠了. 我直接把虚拟机的内 ...
- IntelliJ IDEA 把Maven项目导出可执行jar包
2017年04月05日 14:05:08 waterimelon 阅读数:1574 标签: intellij ideamaven 更多 个人分类: idea 第一步 第二步 第三步
- angluarJs与后台交互小案例
.myService.html: <!DOCTYPE HTML> <html ng-app="app"> <head> <title> ...
- MYSQL 面试常见问题汇总
转自: https://blog.csdn.net/u011010851/article/details/80074550 Q1:主键,外键,超键,候选键:主键 对表中数据进行唯一标识的数据列的 ...
- Codeforces - 518D 概率DP初步
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #i ...