Wednesday, March 7, 2012

Need a little bit of help

Need help
This may seem like a dumb question, but here is what I am trying to do,

Lets say, I have a TABLE that has colums

A B C D

Now, I have added a 5th colum E

I want to populate E with D

I can't seem to get the insert command right,

Anyone ??Hey,

update table t1
set e = (
select t2.d
from table t2
where t1.rowid = t2.rowid);

A more obvious query is to try

update table
set e = (select b from table)

This will not work with the returned error message :

ORA-01427: single-row subquery returns more than one row

This essentially means that for each single row you are trying to update the value e to the results of a query that returns > 1 row.

Cheers.|||Originally posted by r123456
Hey,

update table t1
set e = (
select t2.d
from table t2
where t1.rowid = t2.rowid);

On Oracle,
update t1 set e = d;
would work like a charm.

No comments:

Post a Comment