Jump to content
Sign in to follow this  
ChrisL

SQLITE ADD 1 to Existing Value

Recommended Posts

ChrisL

I'm after a little help with an SQL query.

I've been trying to find out how you add 1 to every value of a single column in a SQLITE table, I'm sure there is an easier way than querying every row and adding 1 but I'm not having much luck finding out how.

I guess you can do something like this...

"UPDATE PRODUCTTABLE SET Product +=1;"

Is it possible to do this?

Ta

Share this post


Link to post
Share on other sites
seandisanti

I'm after a little help with an SQL query.

I've been trying to find out how you add 1 to every value of a single column in a SQLITE table, I'm sure there is an easier way than querying every row and adding 1 but I'm not having much luck finding out how.

I guess you can do something like this...

"UPDATE PRODUCTTABLE SET Product +=1;"

Is it possible to do this?

Ta

one query really is the fastest easiest way to do it; but make sure that you have a where statement unless you want every single row updated. i'm not sure if you can do the increment and assign like that though, may have to actually write out "product = product + 1"
  • Like 1

Share this post


Link to post
Share on other sites
ChrisL
seandisanti

The answer was "UPDATE PRODUCTTABLE SET Product = Product +1;"

:blink:

yeah, i figured that would be the case

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×