Update 1 colum with other column in same table

  • Hi-

    Table TEST

    id width Lengh

    1 0.0 20.0

    2 2.3 1.00

    3 0.0 23.0

    4 1.9 11.0

    I would like to update field "Width" with data in "Length" when Width = 0 and Lengh >0

    then I also want to reset the lengh to blank after that, can you please advise how to do this.

    What I have so far is

    UPDATE TEST

    SET width = lengh

    SET lengh = '' ----Is is okay to do this?

    where width = 0 and length > 0

    Thanks.

    Dee

  • You use a comma to separate the columns in a set. Assuming the length field is numeric you will have to set it to 0 or null depending on the column properties

    UPDATE TEST

    SET width = length

    ,length = 0

    where width = 0 and length > 0

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

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