-1

Can we use AS to create an ALIAS in FROM.If no,why? .If yes,is it limited to only few cases?(because I am getting an error in my case)

ALIAS in FROM without AS works perfectly fine

  SELECT a.id_employee FROM(SELECT id_employee FROM table1 union  SELECT id_employee FROM table2) a;

But why ALIAS in FROM using AS creates error 00933. 00000 - "SQL command not properly ended"

  SELECT a.id_employee FROM(SELECT id_employee FROM table1 union  SELECT id_employee FROM table2) as a;

NOTE: Also I came across the oracle: can you assign an alias to the from clause? explanations which used AS . So can ?

Community
  • 1
  • 1
sql_dummy
  • 715
  • 8
  • 23
  • This is Oracle specific and it is part of its syntax. You probably use MySQL/SQL Server where `AS` is possible for subquery alias, but it is not the case in `Oracle` – Lukasz Szozda Mar 12 '16 at 11:18

1 Answers1

0

Oracle does not allow as in the FROM clause. Oracle only supports as for column aliases.

However, you don't need a subquery for this. It is simpler to use:

SELECT id_employee FROM table1
UNION
SELECT id_employee FROM table2
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786