Chud37 Posted October 12, 2010 Share Posted October 12, 2010 I am writing a poll script. I have an integer field in my DB, and i want to just open the DB, increment a value, and then display the results. Currently i've got three query's running; one to get the current data, one to UPDATE the current data, and one to display the changed data. This seems really rubbish to me. There must be a way to increment an INT field in a DB simply by using SQL. Can anyone help? I just need to plus one. I've looked around and i can't find anything on the subject, or maybe im just not searching the right thing. Anyway, please help. ~Chud37 Quote Link to comment https://forums.phpfreaks.com/topic/215691-easy-one-supposedly-increment-value/ Share on other sites More sharing options...
trq Posted October 12, 2010 Share Posted October 12, 2010 UPDATE tbl SET fld=fld+1 Quote Link to comment https://forums.phpfreaks.com/topic/215691-easy-one-supposedly-increment-value/#findComment-1121411 Share on other sites More sharing options...
Chud37 Posted October 12, 2010 Author Share Posted October 12, 2010 oh my. I searched around and did not find any answers on this, i cant believe it is as simple as that! but it works. Thanks! p.s - i suppose i can perform all the other operations and do some fun algebra in SQL queries? i.e. fld=((fld+1)*5)/4 ? Not that i want to in this point in time, but that would be legal, would it? Sorry for asking silly questions, like i said i couldnt find any documentation on it. Thanks, ~Chud37 Quote Link to comment https://forums.phpfreaks.com/topic/215691-easy-one-supposedly-increment-value/#findComment-1121426 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.