4
votes

I am trying to move from MySQL to Oracle and one of my queries originally looks like this

SELECT t1.table_name 
FROM db_available AS t1 
INNER JOIN db_user_access AS t2 
    ON t1.id=t2.db_id 
WHERE t2.user_id=100 AND t2.expires >= NOW(); 

However, when I run the same query in ORACLE with a minor change...

SELECT t1.table_name 
FROM db_available AS t1 
INNER JOIN db_user_access AS t2 
    ON t1.id=t2.db_id 
WHERE t2.user_id=100 
    AND t2.expires >= SYSDATE;

it gives me the following error:

SQL Error: ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended"

The Oracle SQL Developer tool underlines a problem in the part of the statement

AS t1

I read some other questions that mentioned placing parenthesis around certain parts of the statement for Oracle, however I am just a beginner and don't fully understand Oracle databases yet so I don't really understand where to put them or if they are even needed in this case.

2

2 Answers

3
votes

In you don't need to specify as when aliasing a table:

SELECT t1.table_name 
FROM db_available t1 
INNER JOIN db_user_access t2 
    ON t1.id=t2.db_id 
WHERE t2.user_id=100 
    AND t2.expires >= SYSDATE;
0
votes
SELECT t1.table_name 
FROM db_available t1, db_user_access t2 
WHERE t1.id=t2.db_id 
  AND t2.user_id=100 
  AND t2.expires >= SYSDATE;

Acording to oracle documentation you also don't need to use explicit joins.