update a record with a calculation

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

update a record with a calculation

Post by dstefani »

Hi,

Can I update a price (lower by a percentage) while running an update.

IE: update table SET price = price - (3/100)*price)

So far I can't get this to work, and something tells me I won't. <?>

Thanks,

DJ
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

That should work just fine.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yeah, it should work... although your post may suggest you have a syntax error -- extra parenthesis.
Post Reply