PDA

View Full Version : Search and replace on a MySQL table?


DWZ
05-12-2002, 11:11 AM
Is it possible to make phpMyAdmin, or something else to do a search and replace on some text in a database...

You see, I want it to look at my vB database, go into the smilie table, then find anything that says http://www.consoleradar.com/forums/ and replace it with nothing, blank text.

So yeah, when It finds say http://www.consoleradar.com/forums/images/smilies/smile.gif I want it to change to images/smilies/smile.gif

I could do it manually, It's just a lot of smilies to go through...

so yeah, is there some SQL command I can use or something?

Thanks :)

Alan (DWZ)

Admin
05-12-2002, 11:20 AM
UPDATE tblName SET clmName = REPLACE(clmName, 'findText', 'replaceText');
MySQL Docs:
http://www.mysql.com/doc/S/t/String_functions.html

DWZ
05-12-2002, 11:39 AM
<n00b> I take it I should be replacing tblName and the two clmName bits of text to something else? - Im guessing tblName should be replaced to smilie but I can't work out what clmName is for... and I hate those MySQL docs, i can never work anything out... lol </n00b>

DWZ
05-12-2002, 12:01 PM
OK, FireFly just helped me in the IRC channel...

For anyone who happens to be doing a search and want to know the answer, I used the MySQL command:UPDATE smilie SET smiliepath = REPLACE(smiliepath, 'http://www.consoleradar.com/forums/', '');Thanks FireFly :)

Admin
05-12-2002, 12:35 PM
No problems.

How do people know about the [sql] tag before it's even ready for use? :dead:

DWZ
05-12-2002, 12:43 PM
Originally posted by FireFly
How do people know about the [sql] tag before it's even ready for use? :dead:
* DWZ sees, hears and knows all ;)

Scott MacVicar
05-12-2002, 12:59 PM
/me used it once or twice on some posts, people probably noticed it lol

/me's bad