as with 用法
来源:互联网 发布:淘宝升业绩 编辑:程序博客网 时间:2024/05/16 06:36
今天在网上查找优化的案例,碰巧在一个大神的博客里看到这个用法了,起初还很疑惑,所以就跟着做了下实验:
SQL> create table t2(id int);
Table created.
SQL> create table t1(id int);
Table created.
SQL> insert into t2 values(1);
1 row created.
SQL> insert into t2 values(2);
1 row created.
SQL> insert into t2 values(3);
1 row created.
SQL> insert into t1 values(1);
1 row created.
SQL> select * from t1;
ID
----------
1
SQL> select * from t2;
ID
----------
1
2
3
SQL> with a as (select * from t1),
2 b as (select * from t2)
3 select * fromt2
4 union
5 select * fromt1;
ID
----------
1
2
3
SQL> with a as (select * from t1),
2 b as (select * from t2)
3 select * froma
4 union
5 select * fromb;
ID
----------
1
2
3
SQL> with a as (select * from t1),
2 b as (select * from t2)
3 select * from a
4 union
5 select * from b
6 where id in (2,3);
ID
----------
1
2
3
SQL> with a as (select * from t1),
2 b as (select * from t2)
3 select * from a
4 union
5 select * from b
6 where id not in (2,3);
ID
----------
1
可以看出来where条件只是对每个SELECT语句的表做限制。
- with as 用法
- ORACLE WITH AS 用法
- ORACLE WITH AS 用法
- with as 用法
- WITH AS的用法
- With as 的用法
- WITH AS 用法
- with as的用法
- python with...as...用法
- WITH AS 用法
- SQL - WITH AS 用法
- sql with as 用法
- sql with as 用法
- sql with as 用法
- ORACLE WITH AS 用法
- sql with as 用法
- sql with as 用法
- WITH AS 用法
- Java 的垃圾回收机制
- 8086汇编1,零基础
- 中国开源基础类库 NDKK 开发进展 2013-10-14
- wordpress建站 删除“ 分类目录归档"
- Android 动画 Tweened Animation 之 RotateAnimation
- as with 用法
- java 使窗口居中显示
- 单元测试1
- ramdisk制作
- 适配器模式
- library cache pin和lock等待分析
- 第九届省赛总结
- [各种面试题] 子序列的个数、排列木桩
- Oracle 监听 启动报错 tns-12560 tns-00530 linux error:20:not a directory 解决方法