《SQL.cooker》第三章打卡分享(2)

本文详细讲解了在多种数据库系统中处理不匹配记录的方法,包括使用外连接保持完整数据,以及利用视图检测重复数据。
摘要由CSDN通过智能技术生成

目录:

第三章

3.5在一个表中查找与其他表不匹配的记录

问题

解决方案

----DB2,MYSQL,SQLSEVER,POSTGRESQL-----
select d.* from dept d left outer  join emp e
on d. deptno =e.deptno 
where e.deptno is null
----------------------------------------
---------ORACLE------------------------
select d.* from dept d ,emp e
where  d. deptno =e.deptno (+) and e.deptno is null

3.6,向查询中增加连接但不影响结果

问题

 

解决方案

使用外连接解决,这并不会丢失原始数据

select ename ,loc,received 
from emp e left join dept d
on e.deptno = d.deptno
and e.empno =eb.empno

3.7检测两个表中是否有相同数据 

问题

---考虑视图----
create view v as 
select * from emp e 
where deptno <> 10
unin all 
select * from emp where ename ='ward'
select * from v

视图显示内容如下 

  • 20
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值