我试图写这样的东西。关于outter查询数据的Oracle子查询
SELECT x,
,y
,(Select z from innerTable where innerTable.this = outterTable.that
FROM outterTable
where blahblah
基本上,这个特定的列我想映射到另一个表中的值。但是,当我尝试这样做时,SQLDeveloper只会将我的Select语句打印为列标题,并在其下面有空值。
我试图写这样的东西。关于outter查询数据的Oracle子查询
SELECT x,
,y
,(Select z from innerTable where innerTable.this = outterTable.that
FROM outterTable
where blahblah
基本上,这个特定的列我想映射到另一个表中的值。但是,当我尝试这样做时,SQLDeveloper只会将我的Select语句打印为列标题,并在其下面有空值。
你可以给列一个别名来解决标题:
select x, y,
(Select z from innerTable where innerTable.this = outterTable.that
) as z
from outterTable
where blahblah;
然而,NULL
值是因为没有比赛,所以这是一个不同的问题。
SQL - Relationship between a SubQuery and an Outer Table
我觉得这个很清楚。我想要做的事情会运行得非常慢,因为它会计算结果集中的每一行,所以我最好找到另一种方法来做到这一点。
为什么不使用连接? – JohnHC
你可以请张贴一些样本数据和需要的结果吗?你的表的命名是相当混乱的:为什么你查询“外”表,如果它是“外”? – Aleksej
我不想使用连接,因为此映射仅适用于一列。作为一个子查询来做它似乎更清晰。 – Steve