with as 用法

WITH AS短语,也叫做子查询部分(subquery factoring),可以让你做很多事情,定义一个SQL片断,该SQL片断会被整个SQL语句所用到。有的时候,是为了让SQL语句的可读性更高些,也有可能是在UNION ALL的不同部分,作为提供数据的部分。

WITH AS语句,也称为子查询一部分(subquery factoring),能够 使你做许多事儿,界定一个SQL片段,该SQL片段会被全部SQL语句常用到。有的情况下,是为了更好地让SQL语句的易读性更高些,也是有很有可能是在UNION ALL的不一样一部分,做为给出的数据的一部分。

with as 用法插图

with as 用法

–对于一个别称

with tmp as (select * from tb_name)

–对于好几个别称

with

tmp as (select * from tb_name),

tmp2 as (select * from tb_name2),

tmp3 as (select * from tb_name3),

–相当于建了个e临时表

with e as (select * from scott.emp e where e.empno=7499)

select * from e;

–相当于建了e、d临时表

with

e as (select * from scott.emp),

d as (select * from scott.dept)

select * from e, d where e.deptno = d.deptno;

作者: 791650988

为您推荐

联系我们

联系我们

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部