Change Every Value in a Column

[expired user #2829]'s profile image [expired user #2829] posted 17 years ago in General Permalink
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?
ansgar's profile image ansgar posted 17 years ago Permalink
Oh, that's easy SQL. Just fire an UPDATE statement and "forget" the WHERE clause:
UPDATE table SET colname = '999'
[expired user #2829]'s profile image [expired user #2829] posted 17 years ago Permalink
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.
ansgar's profile image ansgar posted 17 years ago Permalink

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
[expired user #1821]'s profile image [expired user #1821] posted 17 years ago Permalink

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.
[expired user #2829]'s profile image [expired user #2829] posted 17 years ago Permalink

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.
ansgar's profile image ansgar posted 17 years ago Permalink
Also easy: You update column2 with column1 + 1 (or whatever).

UPDATE table SET col2 = col1+1
jan's profile image jan posted 17 years ago Permalink

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.