从存在语句中选择列

发布于 2024-12-03 01:06:55 字数 568 浏览 0 评论 0原文

这是我上一个问题的后续问题:Optimization of an oracle query

我现在使用的查询如下

select t1.column1, t2.column2 
    from table1@dev t1 
  where exists
         ( select *
              from table2@dev 
            where t2.column2 = t1.column1
              and t2.column3 > 0
                    ) 
order by column1

但是问题是我无法从 t2 访问 column2 我收到错误

t2.column2 标识符无效

使用EXISTS 时是否可以访问该表中的列?

提前致谢

This is a follow-up to my previous question: Optimisation of an oracle query

I am now using the query as follows

select t1.column1, t2.column2 
    from table1@dev t1 
  where exists
         ( select *
              from table2@dev 
            where t2.column2 = t1.column1
              and t2.column3 > 0
                    ) 
order by column1

But the problem is I can't access column2 from t2 i'm getting the error

t2.column2 invalid identifier

Is it possible to access the column from this table when using EXISTS?

Thanks in advance

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

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

发布评论

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

评论(1

2024-12-10 01:06:56

Exists(顾名思义)只是检查该事物是否存在,它不会返回超出存在谓词的真/假的任何数据,所以,这是不可能的从 exists 语句返回数据。

要从多个表中选择某些内容,您需要将它们连接起来,如下所示:

select t1.column1, t2.column2      
  from table1@dev t1    
    inner join table2@dev t2 on t2.column2 = t1.column1
 where t2.column3 > 0
 order by t1.column1 

Exists (as the name implies) merely checks if that thing exists, it does not return any data beyond the true/false of the existence predicate, so no, it's not possible to return data from an exists statement.

To select something from multiple tables, you need to join them, like this:

select t1.column1, t2.column2      
  from table1@dev t1    
    inner join table2@dev t2 on t2.column2 = t1.column1
 where t2.column3 > 0
 order by t1.column1 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文