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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

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

Post 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!
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

i don't think you can do that without first knowing value you trying to increment.

HormonX
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

update

Post by AVATAr »

Update TableName set FieldName=FieldName+1 Where Condition
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

Post by rxsid »

AVATAr...thanks!
that's exactly what i needed.
Post Reply