Page 1 of 1

[SOLVED] Editing all values in a row by a curtain number

Posted: Wed Jul 20, 2005 6:07 am
by mickd
Hi, i was just wondering if there was a way to edit all values in a row in a mysql database. any help appriciated. sorry if this question is simple, i must just not be noticing something.

heres an example.

Database

Table example1
ID, Name, Lastname, Number
1, John, Smith, 3
2, David, Spring, 1
etc

im wondering if theres a way to increase all numbers in the number column by 3 for example so itll be

Table example1
ID, Name, Lastname, Number
1, John, Smith, 6
2, David, Spring, 4
etc

thanks for any help.

Posted: Wed Jul 20, 2005 8:50 am
by dreamline
Sure there is, if you want to update an existing field in a dbase just use:

update <tablename> set <fieldname>=<fieldname>+3 <where clause if you want to use it>

As long as your base field has int, bigint, or tinyint it should work fine.. :)

Btw there are no simple questions, right? We all started from scratch.. :)

Posted: Wed Jul 20, 2005 10:05 am
by mickd
cool thanks for the reply, ill check it tomorrow after school hope it work :) 1 am now for me, gotta go sleep :(

EDIT: ok checked worked :)