Orangize Posted July 22, 2003 Share Posted July 22, 2003 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 Quote Link to comment https://forums.phpfreaks.com/topic/759-replacing-a-title/ Share on other sites More sharing options...
shivabharat Posted July 22, 2003 Share Posted July 22, 2003 You can try something like this update <table_name> SET <filed_name> = (replace(<filed_name>,"string1","string2")); Quote Link to comment https://forums.phpfreaks.com/topic/759-replacing-a-title/#findComment-2526 Share on other sites More sharing options...
gizmola Posted July 22, 2003 Share Posted July 22, 2003 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 %\'; Quote Link to comment https://forums.phpfreaks.com/topic/759-replacing-a-title/#findComment-2527 Share on other sites More sharing options...
Orangize Posted July 23, 2003 Author Share Posted July 23, 2003 Thank you so much for the help. It worked perfectly! Quote Link to comment https://forums.phpfreaks.com/topic/759-replacing-a-title/#findComment-2544 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.