Oracle table aliases and "AS" keywords: common errors and solutions
This article discusses a common error when using SQL queries in Oracle database, especially when using the "AS" keyword to set aliases for tables.
Question:
Try executing the following query in Oracle SQL Developer:
<code class="language-sql">SELECT G.Guest_ID, G.First_Name, G.Last_Name FROM Guest AS G JOIN Stay AS S ON G.Guest_ID = S.Guest_ID WHERE G.City = 'Miami' AND S.Room = '222';</code>
The result was an error:
<code>ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause: *Action: Error at Line: 2 Column: 12</code>
Solution:
Unlike other database servers, Oracle Database does not allow the use of the "AS" keyword to alias tables. So just remove "AS":
<code class="language-sql">SELECT G.Guest_ID, G.First_Name, G.Last_Name FROM Guest G JOIN Stay S ON G.Guest_ID = S.Guest_ID WHERE G.City = 'Miami' AND S.Room = '222';</code>
The above is the detailed content of Why Does Using 'AS' for Table Aliasing Cause an ORA-00933 Error in Oracle SQL?. For more information, please follow other related articles on the PHP Chinese website!