PDA

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


DWZ
12 May 2002, 12:11
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)

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

DWZ
12 May 2002, 12:39
<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
12 May 2002, 13:01
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 :)

Chen
12 May 2002, 13:35
No problems.

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

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

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

/me's bad