Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    21

    Unanswered: 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 ??

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    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.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Nov 2002
    Posts
    272
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •