Page 1 of 1

How to do a "selective" table UPDATE...?

Posted: Tue Dec 10, 2002 6:16 pm
by rxsid
Hi all,

not sure how to word this..but here goes:

i have a table with a column of data type smallint.
how could i increase that number that's stored in the smallint by 1...only when certain pages or conditions are meet, in other words...an autoincrement is not wanted here because i don't want to increase that # by one each and every time the table is updated (for other columns).

is it possible to do an UPDATE (with a ++ on the column) on the table w/o first doing a SELECT to get the present number?

thanks!

Posted: Tue Dec 10, 2002 7:50 pm
by HormonX
i don't think you can do that without first knowing value you trying to increment.

HormonX

update

Posted: Tue Dec 10, 2002 10:24 pm
by AVATAr
Update TableName set FieldName=FieldName+1 Where Condition

Posted: Wed Dec 11, 2002 11:11 am
by rxsid
AVATAr...thanks!
that's exactly what i needed.