我需要在第二个查询中使用先前查询结果中的值,同时使用
with clause
示例
with xtable as (
select t1.column1,
t1.column2,
t1.column3,
t1.column4
from table1 t1
where t1.column1 in (1,2)
and t1.column4 = 'ut'
), ytable as
(
select t2.column1,
t2.column2,
t2.column3,
t2.column4
from table1 t2
where t2.column4 = xtable.column2
)select * from xtable,ytable
您可以在第二个查询中添加
xtable
为:
with xtable as (
select t1.column1,
t1.column2,
t1.column3,
t1.column4
from table1 t1
where t1.column1 in (1,2)
and t1.column4 = 'ut'
), ytable as
(
select t2.column1,
t2.column2,
t2.column3,
t2.column4
from table1 t2,xtable x
where t2.column4 = x.column2
)