Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Error 511 [Table of Contents] Error 515

Troubleshooting and Error Messages Guide

[-] Chapter 3 Error Message Writeups
[-] Query Processor Errors
[-] Error 512

Error 512

Severity

16

Error message text

Subquery returned more than 1 value. This is illegal when the subquery follows =, !=, <, <= , >, >=, or when the subquery is used as an expression.

Explanation

When an expression subquery returns more than one result, it violates the relational operator rule for the outer query, and Error 512 occurs.

An example of an expression subquery that returns one result follows:

1> select * from table_one where x =
2> (select sum(a) from table_two
3> where b = table_one.y)
4> go

An example of a query that returns more than one result and causes Error 512 follows:

1> use pubs2
2> go

1> select authors.au_id from authors where
2> authors.au_id = (select titleauthor.au_id
3> from titleauthor)
4> go
Msg 512, Level 16, State 1:
Line 1:
Subquery returned more than 1 value.  This is illegal
when the subquery follows =, !=, <, <= , >, >=, or when 
the subquery is used as an expression.

Action

To correct the problem in the example, use "in" in place of "=", as in the following example:

1> select authors.au_id from authors where
2> authors.au_id in (select titleauthor.au_id 
3> from titleauthor)
4> go
au_id 
----------- 
172-32-1176 
213-46-8915 
  .
  .
899-46-2035 
998-72-3567 

(19 rows affected)

Versions in which this error is raised

All versions


Error 511 [Table of Contents] Error 515