with as 用法

文/
专题:with用法

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;

小编推荐

下载文档

猜你喜欢

专科升本科有几种途径 有哪些方法

23-10-16

冶金工程考研可转专业有哪些 考研难不难

23-10-16

全国计算机等级考试考些什么内容 都有哪些科目

23-10-16

计算机等级证书怎么考 含金量怎么样

23-10-16

2023全国计算机等级考试时间 具体几月几号

23-10-16

雅思4.5分相当于英语几级 算是高分吗

23-10-16

成考大专需要花多少钱 学费贵不贵

23-10-16

全国计算机等级考试考些什么内容 容易通过吗

23-10-16