with as 用法

大学动态,艺考

大学动态

2022-2-11 00:54:51 文/冉冬

关注

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

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;

艺考相关文章

发现更多好内容

艺考用户说说

友善是交流的起点
带你看艺考艺考推送时光机
位置:艺考-高考-高考信息资源-新高考-大学动态-with as 用法
咦!没有更多了?去看看其它艺考内容吧