Forum Moderators: mack
#!/usr/bin/perl
use DBI;
$SQLhost = 'mysqldomain.com';
$SQLname = 'databasename';
$SQLuser = 'username';
$SQLpass = 'password';
$DB = DBI->connect("DBI:mysql:$SQLname:$SQLhost", $SQLuser, $SQLpass);
$DB->do("SELECT fieldname FROM tablename");
$cursor = $DB->prepare($SQL);
$cursor->execute;
while ( @data = $cursor->fetchrow ) {
$DB->do("UPDATE tablename SET fieldname = 'prepended text $data[0]' where fieldname = '$data[0]'");
}
$cursor->finish;
$DB->disconnect;
---------------
This script requires that every record has a unique value for fieldname. Also, I haven't tested it to double-check it.
Hope this helps.