UPDATE The proper trick is described here:
update table set field = replace(field, 'original string','new string');Here is how to replace some text in mysql, using some shell commands.
I am sure somebody can tell me how this can be done in mysql, not using these shell commands.
This specific query is created for Drupal, but it can be modified for any database model.
mysql -u USER -p DATABASE -B -e "select nid,title from node;" \
| sed 's/\.jpg//;s/\.JPG//'| while read nid title ; do echo "update node \
set title=\"$title\" where nid=$nid;"; done > file.txtThe file.txt will look like this:
update node set title="DSCF0233" where nid=1767;
update node set title="DSCF0236" where nid=1768;
update node set title="DSCF0256" where nid=1769;To import this back into mysql:
mysql -u USER -p DATABASE < file.txt| About | Consultancy | Articles | Contact |
|
|
|
|
|
| References | Red Hat Certified Architect | By Robert de Bock | Robert de Bock |
| Curriculum Vitae | By Fred Clausen | +31 6 14 39 58 72 | |
| By Nelson Manning | robert@meinit.nl |