Hi,
I'm trying to run and UPDATE in SQL PLUS. Basically, I have 2 tables - TABLE1 and TABLE2. TABLE1 contains an ID field that links it to TABLE2. TABLE1 has been altered to include a new field called NAME. There are no values for NAME yet in TABLE1 as these need to be taken from TABLE2 NAME where TABLE1 ID = TABLE2 ID.
So I need to loop through a ResultSet of sorts returned from TABLE2 of NAMEs where the IDs equal each other and UPDATE the NAME field in TABLE1 with the value from TABLE2.
I keep getting the error:
ORA-01427: single-row subquery returns more than one row
when I try something like this:
UPDATE TABLE1
SET NAME = (SELECT TABLE2.NAME FROM TABLE1, TABLE2
WHERE TABLE1.ID = TABLE2.ID);
Any suggestions would be appreciated. Thanks.
I'm trying to run and UPDATE in SQL PLUS. Basically, I have 2 tables - TABLE1 and TABLE2. TABLE1 contains an ID field that links it to TABLE2. TABLE1 has been altered to include a new field called NAME. There are no values for NAME yet in TABLE1 as these need to be taken from TABLE2 NAME where TABLE1 ID = TABLE2 ID.
So I need to loop through a ResultSet of sorts returned from TABLE2 of NAMEs where the IDs equal each other and UPDATE the NAME field in TABLE1 with the value from TABLE2.
I keep getting the error:
ORA-01427: single-row subquery returns more than one row
when I try something like this:
UPDATE TABLE1
SET NAME = (SELECT TABLE2.NAME FROM TABLE1, TABLE2
WHERE TABLE1.ID = TABLE2.ID);
Any suggestions would be appreciated. Thanks.