sql92和SQL99的区别
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实现:
-
select e.*,d.dname,c.cname
-
from emp e,dept d,city c
-
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)
-
order by e.sal
②SQL99实现:
-
select * from emp e
-
inner join dept d
-
on e.deptno = d.deptno
-
inner join city c
-
on d.loc =c.cid
-
where e.sal>2000 or e.comm is not null
-
order by e.sal
此外,SQL99中在内连接中还可以使用关键字:using
select * from emp inner join dept using(deptno)
相关文章
SQL标准简介: https://blog.csdn.net/lishuoboy/article/details/108423535
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具