Update using more than one table

  • Hi,

    I have 2 table as A(totalmarks, maths, english, class1) and there is another table B(class2)

    Now i want to do the following,

    Update A

    if class2 > class1

    set totalmarks = maths + english

    how to achieve the above.

  • If I understand you correctly, smth like this:

    update a

    set

    totalmarks = case when b.class2 > a.class1 then maths + english else totalmarks end

    from

    A a

    join B b on -- some join condition

    Upd:

    removed join condition


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • Yup you are right. I had figured it out. i was not knowing that we are able to used from with update. Between thanks for reply:-)

Viewing 3 posts - 1 through 2 (of 2 total)

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