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

The fact is that it returns a single row.

That's what.

SELECT... FROM... WHERE... GROUP BY... HAVING randomNumber > (SELECT value FROM.....) 

Whenever I have signs, such as =,>, it always returns this error to me. When I do IN, it is not.

You should not use comparative signs when comparing with another table?

+6
sql
source share
2 answers

When entering:

 SomeValue IN (SELECT ...) 

this is equivalent to using:

 SomeValue = ANY (SELECT ...) 

Do not use the second notation, but it illustrates the point. When SELECT returns more than one value, you must use ANY or ALL with the comparator. When you omit ANY OR ALL, you must have a SELECT that returns exactly one value.

+6
source share

You can specify multiple values ​​using the IN operator. If you use >, = , < etc., try using this:

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

All Articles