Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing all instances of data in one field with other data

Andrew Kaplan
Super Advisor

Replacing all instances of data in one field with other data

Hi there --

I am running a MySQL 5.x server on a Fedora Core 8 system, and I have the following question:

What command can I use to replace all instances of one data entry in a field with a new one? For example, if I want to replace all instances the tape ID 12345 in the 'local' field with that of 678910 in the same 'local' field, what command would I use? Thanks.
A Journey In The Quest Of Knowledge
1 REPLY
Ivan Ferreira
Honored Contributor

Re: Replacing all instances of data in one field with other data

ALWAYS START WITH A BACKUP!!!

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]
[ORDER BY ...]
[LIMIT row_count]

So, that could be:

UPDATE TABLE_NAME
SET LOCAL=678910
WHERE LOCAL=12345
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?