update data from one table to other table when both have unique identifier.

  • I have two tables.

    Table1 :ONE, COLUMNS are key1, column1, column2

    Table2 :TWO COLUMNS are key2, columnA, columnB

    if ONE.key1 == TWO.key2, then

    update ONE.column1 value into TWO.columnA

    Please help me on this.

  • Is this what you're looking for?

    update Table2

    set columnA = column1

    from Table1

    where key1 = key2;

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi, Thank you for response.

    I am expecting the same.

    But when I am running the specified query, I am getting the following error. 'ORA-00933: SQL command not properly ended.' and

    Mouse cursor points to 'from' key word.

  • That's an Oracle error message, unless I'm much mistaken.

    I'm pretty sure Oracle doesn't support Update From.

    Are you using Oracle? If so, why post the question in an SQL Server 2005 forum on an SQL Server site?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi Friend,

    I am using Oracle server only.

    I have posted for normal SQL help.

    Sorry for not specifying details about database.

    Thank you very much.

  • senapathi_siva (3/23/2009)


    But when I am running the specified query, I am getting the following error. 'ORA-00933: SQL command not properly ended.'

    This is invalid syntax on the Oracle world - not such a thing as "from" clause on update statement.

    Check here for valid update statement constructions ... http://psoug.org/reference/update.html

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply