选择语句上的 SQL 内连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1940579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:49:38  来源:igfitidea点击:

SQL Inner join on select statements

sqloracleora-00933

提问by user235693

I am trying to make an inner join on a select statement like this:

我正在尝试对这样的 select 语句进行内部连接:

select *
from (select* from bars  where rownum <= 10 )as tab1
inner join (select * from bars  where rownum <= 10 )as tab2
on tab1.close=tab2.close

and I get the following error: ORA-00933 SQL command not properly ended Any help would be appreciated, thank you!

并且我收到以下错误:ORA-00933 SQL 命令未正确结束任何帮助将不胜感激,谢谢!

回答by Egor Rogov

Just remove asfrom your query:

只需as从您的查询中删除:

select *
from (select* from bars  where rownum <= 10 ) tab1
inner join (select * from bars  where rownum <= 10 ) tab2
on tab1.close=tab2.close

回答by Wade73

I believe the error comes from you needing a semicolon to end the statement. The select looks fine to me otherwise.

我相信错误来自您需要一个分号来结束语句。否则,选择对我来说很好。

回答by stud

just give a whitespace between ')' and 'as':

只需在 ')' 和 'as' 之间留一个空格:

select * from (select* from bars  where rownum <= 10 ) as tab1
 inner join
 (select * from bars  where rownum <= 10 ) as tab2
 on
 tab1.close=tab2.close

回答by Ozan BAYRAM

select * from 
((select* from bars  where rownum <= 10 )as tab1
inner join (select * from bars  where rownum <= 10 )as tab2
on tab1.close=tab2.close)