-2

I have the simple query:

SELECT t1.JOB_ID 
FROM 
(
  select 1 as JOB_ID 
  from JOBS2
) as t1 
INNER JOIN 
(
   SELECT 2 AS JOB_ID 
   from JOBS
) as t2 ON t1.JOB_ID = t2.JOB_ID;

and I have this error:

Error: ORA-00933: SQL command not properly ended

is it because of the syntax? or it's another problem?

Pablo Glez
  • 306
  • 1
  • 7
  • 20
  • 2
    You know that your query makes no sense? – juergen d Oct 08 '15 at 18:37
  • 1
    I don't know enough about oracle to say why you're getting that error, but your query makes no sense. It's essentially saying "give me all the 1's where the 1 equals 2." What are you trying to do here? – Siyual Oct 08 '15 at 18:39
  • 1
    Possible duplicate of [SQL join subquery](http://stackoverflow.com/questions/18718444/sql-join-subquery) – Becuzz Oct 08 '15 at 18:39
  • Look at the proposed duplicate. The first comment says to remove the AS keywords. I tried that on sql fiddle and it parsed correctly (didn't run because I didn't have a jobs table). – Becuzz Oct 08 '15 at 18:40
  • 1
    http://sqlfiddle.com/#!4/9a9e5/6 wow so weird you can use `AS` on the fieldname but not in the table. – Juan Carlos Oropeza Oct 08 '15 at 18:53
  • 1
    I have a really long query, I don't care about the sens of the query, I just simplified till maximum to see the mistake, cause in sintaxis I based everything in examples like this: http://stackoverflow.com/questions/564997/join-two-sql-queries But I don't care the result, I just want it tu run! – Pablo Glez Oct 08 '15 at 19:19

1 Answers1

1

Remove AS before subqueries names

SELECT t1.JOB_ID 
FROM 
(
  select 1 as JOB_ID 
  from JOBS2
) t1 
INNER JOIN 
(
   SELECT 2 AS JOB_ID 
   from JOBS
) t2 ON t1.JOB_ID = t2.JOB_ID;
Tatiana
  • 1,489
  • 10
  • 19