Need update statement for the following

  • Hello All,

            I have a table with the following data

    Table Name : Door

    ----------------------

    Door_Id   Door_Status

    ========================

    1           0

    2           0

    3           1

    4           1

    5           1

    6           0

    7           1

    8           1

    9           0

    10         1

    --

    --

    --

    --

    Question:

    ===============

    We have to update the table such a way if Door_id = 1 it can update all the record.

    For door_id =1 it can update all the records

    For door_id =2 it can update record no: 2,4,6,8,10 the records

    For door_id =3 it can update record no: 3,6,9 the records

    For door_id =4 it can update record no: 4,8 the records

    For door_id =5 it can update record no: 5,10 the records

    For door_id =6-10 it can update only one record which is equivalent to corresponding

    record no.

    so for example if door_id=2 I need to update row no 2,4,6,8 & 10 for door_status.

    if door_status is 0 make it to 1 or if it is 1 make it 0.

    How to do that in a single update statement??

    Need all of your utmost help.

    Regards


    Thanks & Regards,

    Niladri Kumar Saha

  • Duplicate post...

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=275152

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

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

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