Home » SQL & PL/SQL » SQL & PL/SQL » a subquery returned not exactly one row
a subquery returned not exactly one row [message #23106] Mon, 18 November 2002 13:44 Go to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
Hi

I am trying to update a table in UNIX using Informix-SQL. I get an error message that state a subquery returned not exactly one row. I tried using a declare/open/fetch query, but I don't think that Informix-SQL allows this. My code is simple and is as follows:

update act
set co_no = (select county_no from spk_city
where spk_city.zip = act.zip)
where act.zip in
(select zip from spk_city)

I think the problem is becuase there are duplicate zip codes in the act table. Am I correct?
Re: a subquery returned not exactly one row [message #23107 is a reply to message #23106] Mon, 18 November 2002 13:49 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Yes. To identify the duplicate(s):

select zip, count(*)
  from spk_city
 group by zip
 having count(*) > 1;
Re: a subquery returned not exactly one row [message #23127 is a reply to message #23106] Tue, 19 November 2002 09:30 Go to previous messageGo to next message
Alex Mazur
Messages: 17
Registered: March 2002
Junior Member
update act
set co_no = (select distinct county_no from spk_city
where spk_city.zip = act.zip)
where act.zip in
(select zip from spk_city)
Re: a subquery returned not exactly one row [message #23130 is a reply to message #23127] Tue, 19 November 2002 10:17 Go to previous message
Jon
Messages: 483
Registered: May 2001
Senior Member
I believe this would only work if both zip and county_no are duplicates; if the zip is duplicate but the county_no is not, you will have the same problem. I haven't tested that, but I believe that to be the case.
Previous Topic: Table Stats
Next Topic: Tabular view of normalized table?
Goto Forum:
  


Current Time: Mon Apr 29 03:03:18 CDT 2024