是否可以从子查询访问表?
Select d.table_c.*
from (with table_c as (select *
from table_a)
select *
from table_b
where table_a.id = table_b.id) as d
table_c在d的子查询中,我试图使用d.table_c访问它,但它似乎不起作用。
答案 0 :(得分:1)
您不能将CTE用作子查询。但你可以写下面的内容。
;WITH table_c
as
(SELECT * FROM table_a)
SELECT *
from table_b b
INNER JOIN table_c c on c.id = b.id