locked
help with query - update from 2 tables RRS feed

  • Question

  • hi

    i have 2 tables

        table1: num,X,Y

        table2: num,X,Y

    i need to update X and Y in table1 where table1.num = table2.num

    how to do it ?

    i need it in Oracle query (i think that in sql server it will work too)

    thank's in advance 
    Wednesday, September 15, 2010 8:45 AM

Answers

  • Hmm, it is SQL Server forum, I do not know if it is exact syntax

    MERGE t1
    USING t2 ON t1.id = t2.id
    WHEN MATCHED
        THEN UPDATE SET t1.x= t2.x,t1.y= t2.y


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • Marked as answer by Ai-hua Qiu Thursday, September 23, 2010 8:13 AM
    Wednesday, September 15, 2010 9:33 AM
    Answerer

All replies