在 PostgreSQL 中使用子查询
using subquery with PostgreSQL
我正在尝试执行下面的 select 语句,但出现此错误:
ERROR: more than one row returned by a subquery used as an expression
我尝试更改代码和google如何使它return正确的数据,但我找不到任何有用的东西。
代码如下:
SELECT id, mult(x, y) FROM multTable WHERE (SELECT mult(x, y) FROM multTable) > 20;
请注意,在 multTable 中有 x 和 y 列,它们都有几个值。
如何确保我没有收到该错误消息?
我们将不胜感激。
也许你想要:
SELECT id, mult(x, y) FROM multTable WHERE mult(x, y) > 20;
我正在尝试执行下面的 select 语句,但出现此错误:
ERROR: more than one row returned by a subquery used as an expression
我尝试更改代码和google如何使它return正确的数据,但我找不到任何有用的东西。
代码如下:
SELECT id, mult(x, y) FROM multTable WHERE (SELECT mult(x, y) FROM multTable) > 20;
请注意,在 multTable 中有 x 和 y 列,它们都有几个值。
如何确保我没有收到该错误消息?
我们将不胜感激。
也许你想要:
SELECT id, mult(x, y) FROM multTable WHERE mult(x, y) > 20;