distal-attribute
distal-attribute
distal-attribute
distal-attribute

Change Every Value in a Column

User, date Message
Written by Ethereal
7 years ago
Category: General
3 posts since Sun, 30 Sep 07
I have this table with thousands and thousands of rows. I want to change every value in one column to 999. What would be the fastest way to go about doing this?
Written by ansgar
7 years ago
5009 posts since Fri, 07 Apr 06
Oh, that's easy SQL. Just fire an UPDATE statement and "forget" the WHERE clause:

UPDATE table SET colname = '999'

Written by Ethereal
7 years ago
3 posts since Sun, 30 Sep 07
Keep in mind I'm a noob. I have no idea what that means...

I screamed at my moniter, Update statement,,, "Your Fired!"... with little success.
Written by ansgar
7 years ago
5009 posts since Fri, 07 Apr 06

wrote: I screamed at my moniter, Update statement,,, "Your Fired!"...



:lol: happyI guess we should implement an extension to HeidiSQL which runs a query if you just shout loud enough ;)

Ok,
1. go to the "Query" tab
2. paste the above UPDATE statement into the query editor
3. adjust "table" to match your tablename
4. adjust "colname" to match the column name in your table
5. press the "Play" button or press F9 to "fire" the query
Written by siMKin
7 years ago
104 posts since Sun, 01 Apr 07

wrote: I have this table with thousands and thousands of rows. I want to change every value in one column to 999. What would be the fastest way to go about doing this?

...

Keep in mind I'm a noob. I have no idea what that means...



Don't take this the wrong way, but if you had no idea what anse was talking about you should stay away as far as possible from tables with thousands and thousands of rows .. unless you don't really care what happens to that data.
Written by Ethereal
7 years ago
3 posts since Sun, 30 Sep 07

siMKin wrote:

wrote: I have this table with thousands and thousands of rows. I want to change every value in one column to 999. What would be the fastest way to go about doing this?

...

Keep in mind I'm a noob. I have no idea what that means...



Don't take this the wrong way, but if you had no idea what anse was talking about you should stay away as far as possible from tables with thousands and thousands of rows .. unless you don't really care what happens to that data.



I'm not worried about messing up thousands and thousands of rows. I have everything backed up on my 16gig thumbdrive. These customers financial information are safe with me.


Thanks Anse it actualy worked. That saved me countless hours of going row by row changing the information one by one.



Ok, now I have a backup question. Would it be possible to make all values in one column be greater then the value in another column in the same row. By this I mean. One column states 1000 the next column states 998. I would want to make the next column 1025 just to make sure it's more then the first column.
Written by ansgar
7 years ago
5009 posts since Fri, 07 Apr 06
Also easy: You update column2 with column1 + 1 (or whatever).

UPDATE table SET col2 = col1+1

Written by jan
7 years ago
15 posts since Wed, 15 Aug 07

Ethereal wrote: Keep in mind I'm a noob. I have no idea what that means...



you better ask somebody for help who can give you an lesson of sql.

but as a n00b i recommend extremely not to use heidi or anything to directly connect to mysql. please use the application which the database is for. you can destroy too much!!!!!!
 

Please login to leave a reply, or register at first.