Operating System - Linux
1753650 Members
5805 Online
108798 Solutions
New Discussion

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 1
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?