开发者

SQL : ERROR: more than one row returned by a subquery used as an expression

The thing is that it does return one row.

Here's the thing开发者_运维知识库.

SELECT...

FROM...

WHERE...

GROUP BY...

HAVING randomNumber > (SELECT value FROM.....)

Whenever I have signs such as =, > it always returns me this error. When I do IN it doesn't.

Are you not supposed to use comparison signs when comparing to another table?


When you type:

SomeValue IN (SELECT ...)

it is equivalent to using:

SomeValue = ANY (SELECT ...)

Don't use the second notation - but it illustrates a point. When the SELECT returns more than one value, you must use ANY or ALL with the comparator. When you omit ANY or ALL, then you must have a SELECT that returns exactly one value.


You can specify multiple values with IN operator. If you are using >, = , < etc. try using this:

HAVING randomNUmber > (SELECT MAX(value) FROM ......)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜