从联合查询的结果中选择Oracle

时间:2015-11-02 14:49:32

标签: sql database oracle oracle11g union

我正在尝试对联盟的结果进行选择。我正在运行Oracle 11g。我运行了以下查询,得到ORA-00933: SQL command not properly ended

我查看了很多其他帖子,这应该有效,但不适合我。任何帮助将不胜感激。

SELECT tbl.name
FROM
(
    SELECT name FROM customer
    UNION
    SELECT name FROM vendor
) AS tbl;

2 个答案:

答案 0 :(得分:4)

删除as

SELECT tbl.name
FROM
(
    SELECT name FROM customer
    UNION
    SELECT name FROM vendor
) tbl

答案 1 :(得分:2)

Oracle不支持as表别名。所以,只需删除它:

SELECT tbl.name
FROM (SELECT name FROM customer
      UNION
      SELECT name FROM vendor
     ) tbl;