我想知道是否有办法做这样的事情。
select outsidecolumn, example1, example2
from (
select exemple1,example2
from tablenames
inner joins
where conditions) as p,
table2 tb
where p.example1 = tb.outsidecolumn
答案 0 :(得分:0)
我认为这就是你想要的:
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
答案 1 :(得分:0)
而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