Is it possible to add a number to a unknown number in sql column? For example:
In my sql database is a column named "overallRating". I want to add +1 to whatever number is stored in that column. So if number 14 is stored in overallRating column, +1 would make it 15.
Is this possible to do this without retreving this number from sql first? Something like:
UPDATE MyTable SET overallRating+=1 WHERE url='myurl..'
EDIT When solution was already given:
Actually I haven't tried my code above, but I did now and it also works. I made a syntax error on my first try, that's why I thought it's not working.
The +=
syntax is very new to T-SQL and generally not supported by most PROD systems today and so you just need to spell it out:
UPDATE MyTable SET overallRating=overallRating+1 WHERE ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With