Maybe I am missing something, but why not: UPDATE T SET T.Data = 1 WHERE . . .
With only 2 fields, what could be in your WHERE clause? Hu Qinan wrote: >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. > > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php