Postgres:SELECT AS不工作

时间:2017-07-26 11:12:00

标签: sql postgresql

使用此查询我收到错误,无法弄清楚如何解决。

查询:

SELECT * FROM (
      (SELECT 1), (SELECT  2) 
     )

错误:

syntax error at or near ","

1 个答案:

答案 0 :(得分:1)

你有额外的括号。我也建议使用别名:

SELECT *
FROM (SELECT 1 as a) x CROSS JOIN
     (SELECT 2 as b) y;

或者子查询只返回一行和一列:

SELECT (SELECT 1), (SELECT 2);