Home » SQL & PL/SQL » SQL & PL/SQL » update query
update query [message #4384] Wed, 04 December 2002 08:31 Go to next message
Jay
Messages: 127
Registered: October 1999
Senior Member
I am trying to update the zip field in table1 using the city field from table2 to match up with the city field in table1. When I run the query, I get an error message that says "a subquery returned not exactly one row." I have come to the conclusion that because some cities have multiple zip codes, it doesn't know which zip code to use. Is there anyway around this? I don't care which zip code it uses, just as long as it's one for the correct city.

update act
set zip = (select distinct zip from spk_city
where spk_city.city = act.city)
where state = "IA"
and zip is null

Thanks in advance
Re: update query [message #4390 is a reply to message #4384] Wed, 04 December 2002 11:27 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
update act
   set zip = (select zip
                from spk_city
               where rownum = 1)
 where state = 'IA'
   and zip is null;
Previous Topic: Database triggers
Next Topic: Using Like with :new.val ?
Goto Forum:
  


Current Time: Tue May 14 22:13:52 CDT 2024