Jump to content

Archived

This topic is now archived and is closed to further replies.

Orangize

Replacing a Title

Recommended Posts

I have this 1.1 MB MySQL database set up, and inside the table named lyrics, i have a column named artist. I want to remove all instances of \"The\" in the artist names. I\'ve read something on the web about using the REPLACE command, but I don\'t want to do it individually for each string since I have over 700 records. So I was wondering if you guys could help me out.

 

Thanks a bunch

Share this post


Link to post
Share on other sites

You can try something like this

 

update <table_name> SET <filed_name> = (replace(<filed_name>,"string1","string2"));

Share this post


Link to post
Share on other sites

The sql standard way of doing this would be approximately this:

 

update lyrics

set artist = SUBSTRING(artist, 5)

where UPPER(artist) like \'THE %\';

 

Make sure you do a select first just to make sure that the substring replacement is working right:

 

select SUBSTRING(artist, 5)

from lyrics

where UPPER(artist) like \'THE %\';

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.