A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearIs it possible to decrement a variable in MySQL? - page 1
User InfoPosts
Is it possible to decrement a variable in MySQL?#1
I'm wanting to decrement a variable in a MySQL table by one everytime an UPDATE query is ran.

What I have is this, which isn't working:

UPDATE forum SET replys = reply-- WHERE fid = '$id'

Is this possible in any way, or am I going to have to run a SELECT and get the value first, decrement it, and then insert the new value into the UPDATE query?

posted date: 2008-12-27 14:20:00


Re: Is it possible to decrement a variable in MySQL?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-27 14:20:01


Re: Is it possible to decrement a variable in MySQL?#3
UPDATE forum SET replys = reply - 1 WHERE fid = '$id'

posted date: 2008-12-27 14:31:00


Re: Is it possible to decrement a variable in MySQL?#4
of course:UPDATE forum SET replies=replies-1 WHERE fid = ?

posted date: 2008-12-27 14:33:00


Re: Is it possible to decrement a variable in MySQL?#5
bugger! typed too slowly.

posted date: 2008-12-27 14:34:00


Re: Is it possible to decrement a variable in MySQL?#6
Shouldn't this be replys - 1?

posted date: 2012-04-12 03:03:00


Re: Is it possible to decrement a variable in MySQL?#7
not if you look at the question.

posted date: 2012-04-13 03:54:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.