Update statement

Hello all,

I have a field in my database called
'number' and contains integer values.
How can I run an sql statement and add 15
to all the records?

For example:
I would like to change this:   [itemID], [Name], [Number]
                                              [221], [John White], [1000]
to this:
 [221], [John White], [1015]

So, what it should do is increase the value of 'number' by 15 for all the records in my table.

Thanks
LVL 1
nectarios777Asked:
Who is Participating?
 
hongjunCommented:
Please note it will update ALL records!!!
If this is what you want, then proceed.

To update only certain records, you should do it with a WHERE clause.
E.g.

update yourtablename set Number = Number + 15 where ItemID = 221
0
 
hongjunCommented:
try this

update yourtablename set Number = Number + 15
0
 
nectarios777Author Commented:
hello,

thanks for your answer.
Is there a way to update with random numbers instead of fixed values
such as 15?
0
 
hongjunCommented:
I would suggest you post a new question to address this.

hongjun
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.