如何使用“as”在oracle 10中为连接表设置别名

发布于 2024-09-24 16:41:44 字数 193 浏览 1 评论 0原文

我写了这个,这是错误的语法,帮我修复它,我希望“T”成为两个内部联接结果的别名。

select T.id 
from table1 
  inner join table2 on table1.x = table2.y  
  inner join table3 on table3.z = table1.w as T;

I wrote this, and it is wrong syntax, help me fix it, I want 'T' to be an alias of the result of the two inner joins.

select T.id 
from table1 
  inner join table2 on table1.x = table2.y  
  inner join table3 on table3.z = table1.w as T;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你另情深 2024-10-01 16:41:44

您不能使用别名来命名“整个”连接,但是,您可以在连接的各个表上放置别名:

select t1.id
from table1 t1
   inner join table2 t2 on t1.x = t2.y
   inner join table3 t3 on t3.z = t1.w

在投影中,您必须使用表的别名,它定义了id选择的code>列。

You cannot use aliases to name the "entire" join, you can, however, put aliases on individual tables of the join:

select t1.id
from table1 t1
   inner join table2 t2 on t1.x = t2.y
   inner join table3 t3 on t3.z = t1.w

In the projection, you will have to use the alias of the table, which defines the id column you are going to select.

花之痕靓丽 2024-10-01 16:41:44

您不能直接命名联接的结果。一种选择是使用子查询:

select T.id
from (
  select *
  from table1
  inner join table2 on table1.x = table2.y
  inner join table3 on table3.z = table1.w
) T

另一种选择是子查询分解:

with T as (
  select *
  from table1
  inner join table2 on table1.x = table2.y
  inner join table3 on table3.z = table1.w
)
select T.id
from T

You can't directly name the result of a join. One option is to use a subquery:

select T.id
from (
  select *
  from table1
  inner join table2 on table1.x = table2.y
  inner join table3 on table3.z = table1.w
) T

Another option is subquery factoring:

with T as (
  select *
  from table1
  inner join table2 on table1.x = table2.y
  inner join table3 on table3.z = table1.w
)
select T.id
from T
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文