Saturday, March 17, 2007

How to use MySQL REPLACE function

Here’s a MySQL query fuction that’s easy to forget about: REPLACE. Let’s say I have a bunch of records in a field with http://www and want to quickly change all to http://. Here’s the syntax to update:

UPDATE tdurl_1 SET URL = REPLACE(URL, ‘http://www.tdurl.com/’,'http://tdurl.com/’);

No comments: