• Notice regarding image hosts and attachments. See here.

Increase column value in SQL

Associate
Joined
18 Oct 2002
Posts
2,188
Please bare with me here, i've been thrown in at the deep end at work and i'm a complete noob to SQL. :D

I have a SQL table with a column in which I want to increase all values in it by 1. Is there an SQL command that can do this?

Ive so far tried exporting it as a CSV & increasing all the values in Excel but when i try and import it back using phpmyadmin, I get the following error:

Invalid parameter for CSV import: Lines terminated by

Any ideas?
 
KingAdora said:
I think this should do it:

UPDATE TableName SET ColName = ColName + 1


Although I'd test it first with one row only... because I always do that before blanket updating!

UPDATE TableName SET ColName = ColName + 1 WHERE RowID = XYZ

That's spot on, worked a charm. Thanks very much :)
 
Back
Top Bottom