-- SET操作符:

-- union   联合去重 两个表的字段个数和类型都得一样,起别名 应该在第一个表上操作,,排序按照第一列从小到大来排的

select employee_id, department_id
from employee01
union --union all
select employee_id, department_id
from employee02;

minus  :取差集

-- 使两表字段个数和类型一致

select employee_id emp_id,dapartment_id,to_char(null)
from employees01
union
select to_number(null),department_id,department_name
from departments;

--查询10,50,20部门的job_id,department_id,且department_id 按10,50,20的顺序来排列

column a_dummy noprint;
select job_id,department_id,1 a_dummy
from employees
where department_id = 10
union
select job_id,department_id,2
from employees
where department_id = 50
union
select job_id,department_id,3
from employees
where department_id = 20
order by 3 asc;
JOB_ID     DEPARTMENT_ID
---------- -------------
AD_ASST 10
SH_CLERK 50
ST_CLERK 50
ST_MAN 50
MK_MAN 20
MK_REP 20

--查询所有员工的last_name,department_id和department_name

select last_name,department_id,to_char(null)
from employees
union
select to_char(null), department_id,department_name
from departments;

最新文章

  1. 在Sublime TEXT3中添加brogrammer-theme主题配色方案
  2. 关于 IE6、 IE7兼容性总结(转)
  3. 推荐15款最好的 Twitter Bootstrap 开发工具
  4. sql脚本比较大,sqlserver 无法导入,就用cmd命令执行
  5. 转 DevExpress-ASPxPageControl 动态添加 TabPage 内容
  6. PHP学习笔记 - 进阶篇(5)
  7. ASP.NET页面生命周期总结(1)
  8. box-shadow属性
  9. git远程删除分支但本地git branch -a仍能看到解决
  10. 2. 2A03简介
  11. 探索SQL Server元数据(二)
  12. AXI4
  13. linux下通过curl访问web服务器
  14. VUE 项目刷新路由指向index.html
  15. EJB3 阶段总结+一个EJB3案例 (2)
  16. from setuptools import setup, find_packages ImportError: No module named set
  17. 20145237 Exp9 Web安全基础实践
  18. Java设计模式(9)——观察者模式
  19. 将 Python3 文件打包成 exe 文件
  20. Unity面试问题归总

热门文章

  1. python(If 判断)
  2. golang 容器的学习与实践
  3. 内存迟迟下不去,可能你就差一个GC.Collect
  4. SpringCloudStream学习(四)TTL(存活时间)Dead Letter Exchanges(死信交换机)
  5. spring学习笔记(一)@ConfigurationProperties注解
  6. 有感FOC算法学习与实现总结
  7. hdu5381 The sum of gcd]莫队算法
  8. [hdu5266]区间LCA
  9. pthon-安装新版PyQt5、PyQT5-tool后打不开并Designer.exe提示“This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application the application may fix this program”
  10. python3.x 基础八:socket网络编程