SELECT Subquery Alias - Oracle to MySQL Migration

In Oracle, you can use a SELECT subquery without specifying an alias. In MySQL you have to specify aliases for subqueries in SELECT statements.

Oracle:

  -- No alias in subquery
  SELECT * 
  FROM 
    (SELECT * FROM cities);
  # Ok 
 
  -- Alias 't' is specified (it is optional)  
  SELECT * 
  FROM 
    (SELECT * FROM cities) t;
  # Ok

MySQL:

  -- No alias in subquery (error)
  SELECT * 
  FROM 
    (SELECT * FROM cities);
  # ERROR 1064 (42000): You have an error in your SQL syntax; 
  # check the manual for the right syntax to use near '' at line 3
 
  -- Alias 't' is specified
  SELECT * 
  FROM 
    (SELECT * FROM cities) t;
  # Ok

For more information, see Oracle to MySQL Migration.