Updating Multiple Rows in SQL Server -
i have table looks :
------------------------ |id | status |value| ------------------------ |1 | y |10 | |2 | n |10 | |3 | y |10 | |4 | n |10 | |5 | n |10 | ------------------------
for every status = 'n'
, i'd add 3 value , set status 'y'
. so, outcome table should be:
------------------------ |id | status |value| ------------------------ |1 | y |10 | |2 | y |13 | |3 | y |10 | |4 | y |13 | |5 | y |13 | ------------------------
how can in best way in sql server?
update your_table set status = 'y', value = value + 3 status = 'n'
Comments
Post a Comment