Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Inner join on select statements

Tags:

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

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!

like image 407
user235693 Avatar asked Dec 21 '09 14:12

user235693


People also ask

Can I join a SELECT statement?

To combine two or more SELECT statements to form a single result table, use the set operators: UNION, EXCEPT or INTERSECT.

Can we use inner join in subquery?

With INNER JOIN your Sub-Query will be execute only once and its records may gets stored internally in tempdb worktable on complex operations, then JOINed with the 1st table. With APPLY clause, the Sub-Query will be executed for every row in the 1st table.

Can we use inner join in where clause?

To use the WHERE clause to perform the same join as you perform using the INNER JOIN syntax, enter both the join condition and the additional selection condition in the WHERE clause. The tables to be joined are listed in the FROM clause, separated by commas. This query returns the same output as the previous example.


2 Answers

Just remove as from your query:

select * from (select* from bars  where rownum <= 10 ) tab1 inner join (select * from bars  where rownum <= 10 ) tab2 on tab1.close=tab2.close 
like image 175
Egor Rogov Avatar answered Sep 20 '22 15:09

Egor Rogov


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

like image 21
Wade73 Avatar answered Sep 19 '22 15:09

Wade73