Re: Update SQL problem

From: Chico Khan <chico_at_us1.channel1.com>
Date: 1996/01/24
Message-ID: <31068929.5D8C_at_us1.channel1.com>#1/1


Peter Yates wrote:

> I'm doing an update to a table using a sub-query and get
> ORA-01427 single-row subquery returns more than one row.
> How do I get around this?
>
> update table1
> set day=sysdate
> where table1.id = (select id from table2 where field2 like
> 'BLAH');
Depends. Is 'id' in table2 unique for field2 like 'BLAH'? If so, select distinct(id). If not, then assuming you'd like to update table1 for *each* occurance of 'id' in table2, change the '=' to an 'in'.

The only other scenario (multiple distinct id's in table2 where field2 = 'BLAH', but only one row in table1 one should be updated) is kind of an odd thing to do.

Chico. Received on Wed Jan 24 1996 - 00:00:00 CET

Original text of this message