我想知道是否有办法做这样的事情。
select outsidecolumn, example1, example2
from (
select exemple1,example2
from tablenames
inner joins
where conditions) as p,
table2 tb
where p.example1 = tb.outsidecolumn
我认为这就是你想要的:
select tb.outsidecolumn, p.example1, p.example2
from
(
select exemple1,example2
from tablenames
inner joins
where conditions
) p
inner join table2 tb
on p.example1 = tb.outsidecolumn
并且inner join
虽然执行计划可能相同,但也不是笛卡尔坐标系,但可以说更具可读性。
with p as (
select exemple1,example2
from tablenames
inner joins
where conditions
)
select tb.outsidecolumn, p.example1, p.example2
from p
join table2 tb
on tb.outsidecolumn = p.example1