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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -