A table T contains two fields: T.ID, T.Data. I want to set its T.Data to one of three values: NULL, 0, 1 according to its T.ID.
This is what I have done: 1. Set all Data to be NULL: UPDATE T SET Data = NULL; 2. Create a temporary table Temp to store some selected T.ID. Then update the Data of these records to 1. SELECT ID FROM T WHERE ...; UPDATE T INNER JOIN Temp1 ON T.ID = Temp1.ID SET T.Data = 1; 3. Create another tempory table Temp2 to store selected T.ID. Then update these Data to be 0. SELECT ID FROM Temp1 WHERE... UPDATE T INNER JOIN Temp2 ON T.ID = Temp2.ID SET T.Data = 0; The above sqls are quite efficient, becasue some values are updated three times. Any suggestions for me to simply the above operations? Thanks a lot.