Sign in to follow this  

Calling all SQL gurus..

This topic is 3858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know the correct syntax for updating two floating-point values in an SQL table in this way: UPDATE Table SET value1 = value1 + 0.5, value2 = value2 + 1.61 WHERE id = 'moo' I'm getting syntax errors and I'm not sure what the problem is. Maybe setting two values in this way is illegal? I searched google briefly with not alot of help. Thanks in advance

Share this post


Link to post
Share on other sites
Are the value1/value2 columns actually a float column themselves?

edit: hmmm, actually from that there's two possible causes

a) the value1/value2 columns are non-numeric (eg: not int, float, etc)
b) your id column isn't a char/varchar field

What's the exact error?

Share this post


Link to post
Share on other sites
Hi!

I _think_ that you can't use the values from fields in the statement itself: "value1 = value1 + 0.5".
so, read/select the values1/2 first in a seperate stmt, and set them in a second one.

Cirdan

Share this post


Link to post
Share on other sites
Syntax looks okay apart from the name 'Table'.
I know that in MSSQL 'Table' is a reserved keyword (as in: TRUNCATE TABLE MyTable). Using brackets should fix that:

UPDATE [Table] SET value1 = value1 + 0.5, value2 = value2 + 1.61 WHERE id = 'moo'


/edit: that wasn't it apparently, and 'table' was probably a place holder name anyway. :)

Share this post


Link to post
Share on other sites

This topic is 3858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this