sql92和SQL99的区别

31 篇文章 1 订阅
14 篇文章 0 订阅

SQL92和SQL99都是用来表示多表的联合查询使用的,两者在开发中,具体使用哪一种都是可以的,但是在书写和阅读的过程中,具体表现在以下:

1、笛卡尔积中的区别

①SQL92中的笛卡尔积:select * from emp,dept

②SQL99中的笛卡尔积:select * from emp cross join dept

2、等值连接方面的区别

①SQL92表示:select * from emp,dept where emp.deptno=dept.deptno

②SQL99表示:select * from emp innner join dept on emp.deptno=dept.deptno

3、不等值连接方面

①SQL92表示:select * from emp ,salgrade where emp.sal<=salgrade.hisal and emp.sal>=salgrade.losal

②SQL99表示:select * from emp inner join dept on emp.deptno=dept.deptno where sal>2000

4、左外连接

①SQL表示:select * from emp ,dept where emp.deptno=dept.depetno(+)  【现在数据库不支持】

②SQL99表示:select * from emp left outer join dept on emp.deptno=dept.deptno

5、右外连接

①SQL92实现:select * from emp ,depet where emp.deptno(+)  = dept.deptno;【现在数据库不支持】

②SQL99实现:select * from emp  righ outer join dept on emp.deptno=dept.deptno

6、全完连接

①SQL92实现:select * from emp,dept where epm.deptno(+) = dept.dpetno(+)【现在数据库不支持】

②SQL99实现:select * from emp full outer join dept on emp.deptno=dept.deptno;

7、自连接

①SQL92实现:select e1.*,e2.ename from emp e1,emp e2 where e1.deptno=e2.deptno

②SQL99实现:select e1.*,e2.ename from emp e1 inner join emp e2 on e1.deptno=e2.deptno

8、在三表连接查询中

①SQL92实现:

 
  1. select e.*,d.dname,c.cname

  2. from emp e,dept d,city c

  3. where (e.deptno=d.deptno and d.loc=c.cid and sal>2000) or (e.deptno=d.deptno and d.loc=c.cid and comm is not null)

  4. order by e.sal

②SQL99实现:

 
  1. select * from emp e

  2. inner join dept d

  3. on e.deptno = d.deptno

  4. inner join city c

  5. on d.loc =c.cid

  6. where e.sal>2000 or e.comm is not null

  7. order by e.sal

此外,SQL99中在内连接中还可以使用关键字:using

select * from emp inner join dept using(deptno)

 

 

 

相关文章

SQL标准简介:  https://blog.csdn.net/lishuoboy/article/details/108423535

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

茅坑的小石头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值