Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: cycling values on update, null
03-27-2009, 03:08 AM #1
- Join Date
- Dec 2005
- Thanked 77 Times in 77 Posts
cycling values on update, nullCode:
update table set field = (SELECT CASE field when null then 1 when 1 then 2 else null end)
Any other suggestion how to do this ?
03-28-2009, 07:09 AM #2
A couple of alternatives.
(No SELECT needed, by the by.)Code:update table set field = ( CASE WHEN field IS NULL THEN 1 WHEN field = 1 THEN 2 ELSE null END )
Code:UPDATE table SET field = IF(field IS NULL, 1, IF(field = 1, 2, null) )