Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace entire column in database table 1

Status
Not open for further replies.

bluegnu

Technical User
Sep 12, 2001
131
GB
I have a table with 1300 rows. I have added a switch field that can contain the values "0" or "1", but defaults to "1".

At the moment each of the 1300 records contain a "1", but some of them should contain "0". Is there any way of uploading the values into the table to replace the existing values (rather than having to write a long and boring query)? I have the correct values in an excel spreadsheet at the moment which I can export to text or csv if it would help.

thanks

 
select all the ids of the rows where you want to have "0" instead of "1", save it into a plaintext (cvs) file, where rows are separated with "," so the result looks like

1,
5,
324,
433

this i think could be easy done in excel

now select all the contents of the file, copy it to the clipboard and in an app of your choice connect to mysql and issue this query:

Code:
update your_table_name set the_changed_column_name = 0 where id_column in ( <here paste the contents of the clipboard> )

i hope this works
 
Thanks very much, that has worked a treat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top