请使用以下选择语句查看this SQL fiddle:
select T1.VAL, ttemp.*
from T1,
(select rownum, t.* from (select * from T2 where t2.val = t1.val ) t) ttemp
where t1.val = ttemp.val
and t1.val > 2
在这里,我想将最外层的表与内层-2表连接起来,然后将t2.val > 2
替换为t2.val = t1.val
会导致
ORA-00904: "T1"."VAL": invalid identifier
我认为不为where
添加join
或select * from T2
子句会导致全表扫描。不是吗?
答案 0 :(得分:0)
也许你可以使用它:
SELECT rownum, t1.val, t2.NAME
FROM T1 t1
LEFT JOIN T2 t2 ON (t1.VAL = t2.VAL)
WHERE t1.VAL > 2